Error Installing psycopg2 on Amazon Linux - python

When installing psycopg2 on Amazon Linux using this command: sudo pip-3.4 install psycopg2 I get this output:
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7 (dt dec pq3 ext)" -DPG_VERSION_NUM=90218 -I/usr/include/python3.4m -I. -I/usr/include/pgsql92 -I/usr/include/pgsql92/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from ./psycopg/replication_cursor.h:30:0,
from psycopg/psycopgmodule.c:32:
./psycopg/libpq_support.h:31:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘XLogRecPtr’
typedef unsigned PG_INT64_TYPE XLogRecPtr;
^
In file included from psycopg/psycopgmodule.c:32:0:
./psycopg/replication_cursor.h:47:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr write_lsn; /* LSNs for replication feedback messages */
^
./psycopg/replication_cursor.h:48:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr flush_lsn;
^
./psycopg/replication_cursor.h:49:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr apply_lsn;
^
In file included from psycopg/psycopgmodule.c:33:0:
./psycopg/replication_message.h:46:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr data_start;
^
./psycopg/replication_message.h:47:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr wal_end;
^
error: command 'gcc' failed with exit status 1
I already have gcc, postgresql-devel, postgresql-libs, and python34-devel installed. Am I missing a package or setting?
Edit: This is on an EMR node.

I have the same problem with EMR, I tried below
sudo yum -y install gcc python-setuptools python-devel postgresql-devel
sudo /usr/bin/pip install --upgrade pip
sudo /usr/local/bin/pip install psycopg2
It works when I'm running it on EMR but doesn't work when EMR is spin up from Pipeline.

If you are trying to install psycopg2 for python3 you must install python3-devel as well.
To find the correct package
yum search python3 | grep devel
In my case it was python36-devel so I did
sudo yum install python36-devel
And then I could install psycopg2 for my python3 virtualenvironment on the machine

If you're looking for psycopg2 for python3 in amazon linux, this is what worked for me:
sudo yum install -y gcc postgresql-devel
sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python36
sudo pip-3.6 install -U psycopg2

Related

I can't able to install the psycopg2 in python 3.10.8 in ubuntu-20 | ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory [duplicate]

This question already has answers here:
How to install libpq-fe.h?
(4 answers)
Closed 3 months ago.
I'm Using python3.10.8 & ubuntu-20, i have tried so many commands But I can't able to fixe that.
Error:
r-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120012 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/softsuave/Downloads/charityape/skraggle-main (2)/skraggle-main/venv/include -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-3.10/psycopg/adapter_asis.o -Wdeclaration-after-statement
In file included from psycopg/adapter_asis.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.h>
| ^~~~~~~~~~~~
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with
pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> psycopg2
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Commands I had Tried
sudo apt-get install python3-dev
sudo apt-get install python3.10-dev
Reference Documentations CLICK HERE
try
pip install psycopg2-binary
or you can try this
sudo apt-get install libpq-dev

error while installing python-mcrypt-1.1 in virtual env - fatal error: mcrypt.h: No such file or directory

I am trying to install python-mcrypt-1.1 with below command
pip install http://labix.org/download/python-mcrypt/python-mcrypt-1.1.tar.gz
but i am getting below error i have tried with sudo permission as well but not able to install and getting below error
running install
running build
running build_ext
building 'mcrypt' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DVERSION="1.1" -I/usr/include/python2.7 -c mcrypt.c -o build/temp.linux-x86_64-2.7/mcrypt.o
mcrypt.c:23:20: fatal error: mcrypt.h: No such file or directory
#include <mcrypt.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
python-mcrypt is a Python interface to the mcrypt library. You have to install mcrypt first.
found the solution for this issue .
For mcrypt.h, libmcrypt-dev needs to install by following command
sudo apt-get install libmcrypt-dev
after installing with above command python-crypt got install successfully with below command
pip install http://labix.org/download/python-mcrypt/python-mcrypt-1.1.tar.gz

python gcc and setuptools error during lxml installation

I am trying to install LXML on centos (amazon linux AMI).
I have installed the following prereqs:
sudo yum install libxml2-devel libxslt-devel
sudo yum install zlib-devel
sudo pip install setuptools
sudo yum install python-devel
I then install lxml with:
sudo pip install lxml
I get the following gcc error:
creating build/temp.linux-x86_64-2.7/src/lxml
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o
build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
{standard input}: Assembler messages:
{standard input}:593226: Error: unknown pseudo-op: `.lc1'
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See http://bugzilla.redhat.com/bugzilla for instructions.
Compile failed: command 'gcc' failed with exit status 4
creating tmp
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInit0HczkK.c -o tmp/xmlXPathInit0HczkK.o
cc tmp/xmlXPathInit0HczkK.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 4
----------------------------------------
Command "/usr/bin/python2.7 -c "import setuptools,
tokenize;file='/tmp/pip-build-TmaL5z/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file,
'exec'))" install --record /tmp/pip-OD8Xpx-record/install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-TmaL5z/lxml
My gcc version is:
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
My python version is:
Python 2.7.12
How can I get past this error to install LXML ?
I installed those I mentioned above:
sudo yum install libxml2-devel libxslt-devel
sudo yum install zlib-devel
sudo pip install setuptools
sudo yum install python-devel
And these two did the trick:
sudo yum install glibc-devel glibc-headers
Sudo yum groupinstall "Development tools”
sudo pip install lxml

Can't install openssl-devel for Python 2.7.11

when i install the cryptography,there have some errors,for the platform is :
[root#RHanible ~]# python -V
Python 2.7.11
[root#RHanible ~]# rpm -qa openssl
openssl-1.0.0-20.el6.x86_64
[root#RHanible ~]# rpm -qa openssl-devel
openssl-devel-1.0.0-20.el6.x86_64
[root#RHanible ~]# rpm -qa python-devel
python-devel-2.6.6-29.el6.x86_64
[root#RHanible ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)
the errors is following:
already up-to-date
building '_openssl' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/python/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
build/temp.linux-x86_64-2.7/_openssl.c:2078: warning: function declaration isn?. a prototype
build/temp.linux-x86_64-2.7/_openssl.c:2079: warning: function declaration isn?. a prototype
build/temp.linux-x86_64-2.7/_openssl.c:2080: warning: function declaration isn?. a prototype
build/temp.linux-x86_64-2.7/_openssl.c:2105: warning: function declaration isn?. a prototype
build/temp.linux-x86_64-2.7/_openssl.c:2163: warning: function declaration isn?. a prototype
build/temp.linux-x86_64-2.7/_openssl.c: In function ?.cffi_const_CMS_DEBUG_DECRYPT?.
build/temp.linux-x86_64-2.7/_openssl.c:8193: error: ?.MS_DEBUG_DECRYPT?.undeclared (first use in this function)
build/temp.linux-x86_64-2.7/_openssl.c:8193: error: (Each undeclared identifier is reported only once
build/temp.linux-x86_64-2.7/_openssl.c:8193: error: for each function it appears in.)
error: command 'gcc' failed with exit status 1
I used following steps and it worked for me on my virtual environment. First, I installed python development headers and libevent headers.
sudo apt-get install python-dev
sudo apt-get install libevent-dev
then, I used documentation
https://cryptography.io/en/latest/installation/#building-cryptography-on-linux

Aspell PIL can't install with setup.py Python 3

Terminal Error Return
root#sys:~/Downloads/PIL-fork-1.1.7-py3# python3 setup.py build
running build
running build_py
running build_ext
building 'PIL._imaging' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python3.2mu -c _imaging.c -o build/temp.linux-x86_64-3.2/_imaging.o
_imaging.c:75:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
root#sys:~/Downloads/PIL-fork-1.1.7-py3#
this file are downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil
how to install this Aspell PIL Python 3?
Following below step to complete install PIL
sudo aptitude install python3-setuptools
sudo easy_install3 pip
sudo apt-get install python3-dev
download the Pillow-master.zip
wget https://github.com/python-imaging/Pillow/archive/master.zip
go to downloaded directory and,
sudo unzip Pillow-master.zip
python3 setup.py build
python3 setup.py install

Categories