Postgres DB is already installed. I'm not using system perl I have installed another perl in "/srv/data203806/Migration/CPAN/localperl/bin". When I'm trying to install, It is asking for PATH TO pg_config:
[root1#frmrszvwb023 bin]# ./cpan install DBD::Pg
Reading '/root/.cpan/Metadata'
Database was generated on Fri, 07 Mar 2014 03:53:02 GMT
Running install for module 'DBD::Pg'
Running make for T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz
Checksum for /root/.cpan/sources/authors/id/T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz ok
CPAN.pm: Building T/TU/TURNSTEP/DBD-Pg-3.0.0.tar.gz
Configuring DBD::Pg 3.0.0
Path to pg_config?
No POSTGRES_HOME defined, cannot find automatically
Warning: No success on command[/srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL]
'YAML' not installed, will not store persistent state
TURNSTEP/DBD-Pg-3.0.0.tar.gz
/srv/data203806/MUXmh-Migration/CPAN/localperl/bin/perl Makefile.PL -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
Please help me to install DBD::Pg? How to get path to pg_config?
Just ran into this issue, and on Ubuntu 16.04 Xenial the package you're looking for is:
apt-get install libdbd-pg-perl
You have to install libpq-dev, e.g. on Ubuntu:
sudo apt-get install libpq-dev
On CentOS/RH you can fix it by installing perl-DBD-Pg package with yum
sudo yum install perl-DBD-Pg
From the README:
INSTALLATION:
Before installing, please use the "cpansign -v" program to
cryptographically verify that your copy of DBD::Pg is complete and
valid. The program "cpansign" is part of Module::Signature, available
from CPAN.
By default Makefile.PL uses App::Info to find the location of the
PostgreSQL library and include directories. However, if you want to
control it yourself, define the environment variables POSTGRES_INCLUDE
and POSTGRES_LIB, or define just POSTGRES_HOME. Note that if you have
compiled PostgreSQL with SSL support, you must define the POSTGRES_LIB
environment variable and add "-lssl" and "-lcrypto" to it, like this:
export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"
The usual steps to install DBD::Pg:
perl Makefile.PL
make
make test
make install
Do steps 1 to 2 as a normal user, not as root!
If the script cannot find the pg_config information itself, it will
ask you for the path to it. Enter the complete path to the pg_config
file here, including the name of the file itself.
If you want to use a module, read the documentation.
Before installing perl module, you must install client for accessing Postgres DB. I just install server and header files:
sudo apt-get install postgresql
sudo apt-get install libpq-dev
You can try:
locate pg_config
This will show something like:
/usr/pgsql-10/bin/pg_config
/usr/pgsql-10/include/ecpg_config.h
/usr/pgsql-10/include/ecpg_config_x86_64.h
Then run:
POSTGRES_HOME=/usr/pgsql-10 ./cpan install DBD::Pg
UPD
If you still encounter issues with pg_config, you may need to add it to your PATH, e.g.:
export PATH=$PATH:/usr/pgsql-x.x/bin
where x.x is your version, such as /usr/pgsql-9.2./bin.
Fedora 29, plenv, perl v5.18.0
Once I got plenv working, I was able to install DBD::Pg with cpanm using these commands:
sudo dnf install postgresql postgresql-devel
cpanm --quiet --notest DBD::Pg
For ArchLinux (or any Distro using Pacman):
pacman -S perl-dbd-pg
For my Ubuntu 22 worked this:
sudo apt install build-essential
sudo apt install cpanminus
sudo apt-get install -y postgresql-server-dev-all
sudo cpanm DBD::Pg
Related
I used Ubuntu 18.04 LTS for Windows from Microsoft store and tried to install BioPerl module Bio::SeqIO with cpanm Bio::SeqIO. Perl version is v5.26.1. It seems that module installation failed:
! Installing the dependencies failed: Module 'XML::Twig' is not installed, Module 'XML::LibXNL::Reader' is not installed, Module 'XML::LibXML' is not installed, Module 'XML::Parser::PerlSAX' is not installed, Module 'XML::DOM::XPath' is not installed, Module 'XML::DOM' is not installed
! Bailing out the installation for BioPerl-1.7.7
58 distributions installed
If i run a script with line use Bio::SeqIO; I get an error:
Can't locate Bio/SeqIO.pm in #INC (you may need to install the
Bio::SeqIO module) (#INC contains: ...
I am not sure how to proceed. I could try to install dependencies that failed with cpanm but I do not know if it is a proper way.
I tried this on my Windows 10 laptop:
Installed WSL Ubuntu 18.10 as described here, then
Using the system perl, i.e /usr/bin/perl (maybe it would have been better to use perlbrew and installed a custom perl and such avoid using sudo) from the Linux terminal window:
sudo apt-get update
sudo apt-get -y install make gcc libexpat1-dev
sudo cpan local::lib
sudo cpan App::cpanminus
sudo cpanm -n Time::Zone # <-- failed tests
sudo cpanm -n XML::DOM::XPath # <-- failed tests
sudo cpanm Bio::SeqIO
This worked for me.
Perhaps sudo apt-get install bioperl bioperl-run would install all modules which you might need in feature.
Bioperl
I use command:
cpanm --sudo --interactive Filter::Crypto
I am always asked for location of openssl.
Then I run command:
dpkg -L openssl
I get many paths.
I dont know what should I do next.
thanks
To install this module, the develop files of openssl are needed. Under Ubuntu, it needs to install package: libssl-dev to get develop files to be installed: so after running sudo apt-get install libssl-dev, the problem is resolved.
In CentOS, install openssl-devel package.
Here is the stdout for install:
$sudo cpanm XML::LibXML
--> Working on XML::LibXML
Fetching http://www.cpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0014.tar.gz ... OK
Configuring XML-LibXML-2.0014 ... N/A
! Configure failed for XML-LibXML-2.0014. See /home/kahmed/.cpanm/build.log for details.
details:
Unpacking XML-LibXML-2.0014.tar.gz
Entering XML-LibXML-2.0014
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.55_02)
Configuring XML-LibXML-2.0014
Running Makefile.PL
enable native perl UTF8
running xml2-config...ok (2.9.0)
Checking for ability to link against xml2...no
Checking for ability to link against libxml2...libxml2, zlib, and/or the Math library (-lm) have not been found.
Try setting LIBS and INC values on the command line
Or get libxml2 from
http://xmlsoft.org/
If you install via RPMs, make sure you also install the -devel
RPMs, as this is where the headers (.h files) are.
Also, you may try to run perl Makefile.PL with the DEBUG=1 parameter
to see the exact reason why the detection of libxml2 installation
failed or why Makefile.PL was not able to compile a test program.
-> N/A
-> FAIL Configure failed for XML-LibXML-2.0014. See /home/kahmed/.cpanm/build.log for details.
i tried installing libxml2 manually, but still getting the same issue.
also, i checked for libxml2-dev:
sudo apt-get install libxml2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libxml2-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 78 not upgraded.
here is the system info:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 11.04
Release: 11.04
Codename: natty
uname -a
Linux autobot 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
I think the relevant line is:
Checking for ability to link against libxml2...libxml2, zlib, and/or the Math library (-lm) have not been found.
So, you've covered off libxml. Have you installed the appropriate zlib package? Try:
sudo apt-get install zlib1g-dev
Then try installing XML::LibXML again.
Why do you want to use CPAN for this anyway? It is typically very bad idea to install CPAN packages if you have native packages provided by standard operating system installer.
Ubuntu provides a lot of Perl packages natively, with following naming convention: package name always starts with lib, then Perl package name like XML::LibXML is converted to lower case and :: replaced to dash - (XML::LibXML => xml-libxml), and finally -perl suffix is added. In other words, native package name for XML::LibXML would be libxml-libxml-perl.
So, in your case, you simply run this command and it will pull all necessary dependencies automatically:
sudo apt-get install libxml-libxml-perl
If you don't like this package for any reason you can uninstall it with sudo apt-get remove. If you use CPAN, it is very difficult to uninstall it reliably.
Overlooked the obvious:
sudo apt-get install --reinstall zlibc zlib1g zlib1g-dev
then:
sudo cpanm XML::LibXML
works!
Maybe this is new version. I did:
sudo apt-get install libxml2-dev
After this module builded and installed successfully
Is it possible to install psycopg2 into a virtualenv when PostgreSQL isn't installed on my development system—MacBook Pro with OS X 10.6?
When I run pip install psycopg2 from within my virtualenv, I received the error shown below.
I'm trying to connect to a legacy database on a server using Django, and I'd prefer not to install PostgreSQL on my development system if possible.
Why not install PostgreSQL?
I received an error when installing PostgreSQL using homebrew. I have Xcode4—and only Xcode4—installed on my MacBook Pro and am thinking it's related to missing gcc 4.0. However, this is a problem for another StackOverflow question.
Update 8:37 AM on April 12, 2011: I'd still like to know if this is possible without installing PostgreSQL on my MacBook Pro. However, I ran brew update and forced a reinstallation of ossp-uuid with brew install --force ossp-uuid and now brew install postgresql works. With PostgreSQL successfully installed, I was able to pip install psycopg2 from within my virtualenv.
Error from pip install psycopg2
$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matthew/.pip/pip.log
Preliminary Research
Below are the articles I read as preliminary research:
Installing psycopg2 to use Django with PostgreSQL on OS X
Installing psycopg2 on OS X
Using psycopg2 with virtualenv on Ubuntu JauntyLucid
Postgres, psycopg2, virtualenv install hints
apt-get install libpq-dev
helped me on debian squeeze
From comments:
apt-get install python-dev-is-python3
psycopg depends on pg_config command, and if you don't have it, you can't install psycopg.
If system installation is a problem to you, why don't you try compiling PostgreSQL and including generated bin files in your $PATH? Like:
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
pip install psycopg2
brew install postgresql
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip3 install psycopg2
apt-get install libpq-dev
helped me in debian squeeze too . After that do pip install psycopg2. I faced problem of pg_config not found problem when i was setting up my environment on heroku , now its working fine .
You need to install the python-dev package in order to make use of python extensions such as psycopg2. I don't know how to install packages in mac but I run the following commands to install a python package on my Ubuntu machine.
sudo apt-get install python-dev
Or
sudo apt-get install python3-dev
if you are using Python3.x.
Once the installation is finished run the following command within your virtual environment.
pip install psycopg2
You don't need the complete PostgreSQL installed: you only need the client side libraries.
I solved it in MAC OSX using :
$ wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.bz2
$ tar xfv postgresql-9.5.3.tar.bz2
$ cd postgresql-9.5.3
$ ./configure
$ make
$ cd src/bin/pg_config
$ export PATH=`pwd`:"$PATH"
$ pip install psycopg2
Use pip install psycopg2-binary, it worked for me when pip install psycopg2 wasn't working.
Using the method you described in your April 12th update, I was able to install PostgreSQL(+1). Note that I originally was running Python 2.7.1 (32bit) and homebrew threw several errors and warnings regarding using a 32bit version of Python. I have since switched the 64/32 bit version of 2.7.1 and it works like a champ.
Regarding the pyscopg2, I was able to install it into my virtual environment from source by editing setup.cfg. I set pg_config to correct path inside homebrew's Cellar (pg_config=/usr/local/Cellar/postgresql/9.0.4/bin/pg_config). After saving the changes, I ran python setup.py install with zero issues. It's worth noting that I did not set the Mac's default python setting to 32 bit. I used the new 64 bit from start to finish.
After looking over some of the documentation, I think if I added homebrew's postgresql path to the system path I could have used pip to install it.
Reference:
http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html
Update 6-8-2011:
While porting a project written on OS X to Windows 7, I found out that I had to install PostgreSQL on Windows as well. This ended up creating another user on my start up screen and other things that I just didn't like. While doing some digging I found Windows drivers for PostgreSQL here. I have since uninstalled the full PostgreSQL and installed the ODBC drivers which, thus far, work great.
To address the original question, after doing a bit more digging I think I found the equivalent ODBC for OS X here. I have not had a chance to try them out, but the concept works very well on Windows 7. I will update this when I get a chance to try them out. Until then, I hope this helps.
All from the above doesn't work for me (OS Catalina 10.15.1)
There was a conflict with classical postgres and homebrew version.
Please delete homebrew version by command
$ brew uninstall postgresql
and then install it from the official website:
$ sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
It is actual for a simple psycopg2 install or django-heroku package.
if you have recently updated python or changed default python (let's say from 3.6 to 3.8). The following code
sudo apt-get install python-dev OR sudo apt-get install python3-dev
will be installing/working for the previous python version.
so if you want this command to work for the recently updated/changed python version try mentioning that specific version like python3.8 in command like
sudo apt-get install python3.8-dev
try above with following
pip install wheel
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
sudo apt-get install libpq-dev
sudo apt-get install python3.x-dev **Change x with your version, eg python3.8**
pip install psycopg2-binary
pip install psycopg2
As I never needed to install postgresql database on this server I installed the following libraries on Ubuntu 14_04 version before running pip install psycopg2 on the same server
apt-get install libpq-dev python-dev
and then executed pip install psycopg2 within virtual env.
Output
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2
Stored in directory: /root/.cache/pip/wheels/e2/9a/5e/7b620848bbc7cfb9084aafea077be11618c2b5067bd532f329
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.6.1
I know you are asking for development environment but if you are deploying on server say, Heroku.
Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.
Try to specify the version and it'll works, do it inside the venv
pip install psycopg2-binary==2.8.6
based on my experience, apt install libpq-dev then try to install psycopg2 inside venv will fix many issues, however for more information you can refer to this link:
https://www.psycopg.org/docs/install.html
I just tried Ora2Pg on my Ubuntu Jaunty Jackalope.
First of all, the installation was hard, but after downloading a few debs & rpms here & there, I was finally managed to install ora2pg via synaptic.
However, when I try to run this command
ora2pg /tmp/ora2pg.conf
I am getting a
install_driver(Oracle) failed: Can't load '/usr/lib/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at /usr/lib/perl/5.10/DynaLoader.pm line 196.
at (eval 14) line 3
Compilation failed in require at (eval 14) line 3.
Perhaps a required shared library or dll isn't installed where expected
at /usr/share/perl5/Ora2Pg.pm line 566
Any ideas what's wrong and how to fix it?
Note: I don't perl. I just started browsing a bit it because of this.
This is the correct sequence for installation:
apt-get install libdbi-perl
apt-get install alien dpkg-dev debhelper build-essential
apt-get install libaio1
apt-get install make
apt-get install alien
apt-get install rpm
apt-get install libpq-dev
download DBD-Oracle-1.74 or last version
download DBD-Pg-3.5.3 or last version
download DBI-1.636 or last version
download ora2pg-17.5 or last version
download oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
download oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
download oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
after extract rpm package and install:
alien oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
alien oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
alien oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
dpkg -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.deb
dpkg -i oracle-instantclient12.1-devel_12.1.0.2.0-2_amd64.deb
dpkg -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.deb
then:
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
the path of oracle client installation
export ORACLE_HOME=/usr/lib/oracle/12.1/client64/
then, istall the perl extension for Oracle and Postgres
cd DBI-1.636
perl Makefile.PL
make && makeinstall
cd DBD-Oracle-1.74 o DBD-Oracle-1.64
perl Makefile.PL
make && makeinstall
cd DBD-Pg-3.5.3
perl Makefile.PL
make && makeinstall
and finally, install
cd ora2pg-17.x
perl Makefile.PL
make && makeinstall
check in the version is correct
ora2pg -v
and last configure ora2pg.conf on /etc/ora2pg/
insert in file, the configuration for connect to Oracle and Postgres.
DBD::Oracle can't find the Oracle client libraries because they're not in your library path. If you don't have the Oracle client libraries and you don't have a sysadmin to provide them for you, then you need to get the "Oracle Instantclient" package from the oracle website and install it. If you already have Instantclient installed, then you need to add its lib directory (something like /usr/lib/oracle/instantclient/lib or /opt/ora/instantclient10_1/lib) to your library path -- either by adding a line to /etc/ld.so.conf and running ldconfig as root, or by setting the LD_LIBRARY_PATH environment variable.
Pre-installation steps:
ORACLE Client must be installed and ORACLE_HOME must be set.
Install perl (version 5.6 and above)
Installation steps:
Install DBI (database interface module)
apt-get install cpanminus (for ubuntu)
yum install cpanminus (for Linux)
cpanm DBI
Install DBD::Oracle and DBD::Pg
cpanm DBD::Oracle
cpanm DBD::Pg
Download the latest version of ora2pg from http://sourceforge.net/projects/ora2pg/ and run the following commands:
tar -xvf ora2pg-18.0.tar
cd ora2pg-18.0/
perl Makefile.PL
su root
make
make install
Do the changes as per req
By default Ora2Pg will look to ora2pg.conf configuration file into /etc/ora2pg/ directory.
ORACLE_HOME /app/oracle/product/11.2.0
ORACLE_DSN dbi:Oracle:host=[hostname];sid=[SID name]
ORACLE_USER [SYSTEM]
ORACLE_PWD [password]
USER_GRANTS 1
Check the version of pra2pg:
ora2pg SHOW_VERSION
Run the below command
ora2pg -c /etc/ora2pg/ora2pg.conf
ora2pg -c /etc/ora2pg/ora2pg.conf -p -P 10 -J 10 -L 1000000
.sql file will create in the current directory have converted data into PostgreSql
Hope this will work.