Installing psycopg2 in an alpine docker container - python

I am trying to get my django application to use PostgreSQL, however, so far no luck. I set the application to use the PostgreSQL database and linked both containers using docker-compose.yml, but I am getting the error that the module psycopg2 is missing. I installed all of the dependencies as follow: apk --update add python3-dev, postgresql-client, postgresql-dev, musl-dev and when I try to install psycopg2 using pip pip3 install psycopg2 I get the following error:
Collecting psycopg2
Downloading psycopg2-2.6.2.tar.gz (376kB)
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2
creating build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/psycopg
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -fomit-frame-pointer -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090409 -DHAVE_LO64=1 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-6wmwilb_/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-f8ye_ro8-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6wmwilb_/psycopg2
Am I missing a dependency or am I installing psycopg2 wrong?

Add this in the Dockerfile of your django app
RUN apk add build-base
It is like build-essentials, include basic build tools for compiling C/C++
programs

Related

Can't Install psutil

Can someone help me understand why I can't install psutil? I'm on MacOS. I'm a noob so bear with me, but any help would be appreciated. Could it be something to do with the default Python install vs v3 that I installed? I'm new to command line so confused about what is causing the error and how to fix it...
This is the error message I get...
kasey#MacBook-Pro ~ % pip3 install psutil
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting psutil
Downloading psutil-5.7.0.tar.gz (449 kB)
|████████████████████████████████| 449 kB 150 kB/s
Building wheels for collected packages: psutil
Building wheel for psutil (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-wheel-dsejsf
cwd: /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/
Complete output (43 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.15-x86_64-2.7
creating build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psaix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
creating build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/runner.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_process.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_system.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/__main__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
running build_ext
building 'psutil._psutil_osx' extension
creating build/temp.macosx-10.15-x86_64-2.7
creating build/temp.macosx-10.15-x86_64-2.7/psutil
creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch
creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch/osx
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_OSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c psutil/_psutil_common.c -o build/temp.macosx-10.15-x86_64-2.7/psutil/_psutil_common.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psutil
Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil
Running setup.py install for psutil ... error
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-record-O5uazE/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/kasey/Library/Python/2.7/include/python2.7/psutil
cwd: /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/
Complete output (43 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.15-x86_64-2.7
creating build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psaix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil
creating build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/runner.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_process.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_system.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_memory_leaks.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
copying psutil/tests/__main__.py -> build/lib.macosx-10.15-x86_64-2.7/psutil/tests
running build_ext
building 'psutil._psutil_osx' extension
creating build/temp.macosx-10.15-x86_64-2.7
creating build/temp.macosx-10.15-x86_64-2.7/psutil
creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch
creating build/temp.macosx-10.15-x86_64-2.7/psutil/arch/osx
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_OSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c psutil/_psutil_common.c -o build/temp.macosx-10.15-x86_64-2.7/psutil/_psutil_common.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"'; __file__='"'"'/private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-install-HsBPVK/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4h/g406694s1hb_rc1vwchcn08c0000gn/T/pip-record-O5uazE/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/kasey/Library/Python/2.7/include/python2.7/psutil Check the logs for full command output.
This happens when you have multiple versions installed (as for me, I had python 3.5 along with 3.7 installed), you have to specify a granular version, like so (for 3.7):
sudo apt-get install python3.7-dev -y
Read more:
https://github.com/giampaolo/psutil/issues/1143#issuecomment-334695523
For the same issue on AWS for python3, you will likely need to specify the version more explicitly:
yum install python36-devel.x86_64
Or just search for the right package name:
yum search python | grep -i dev

python - can't install psycopg2 on centos 7

I'm trying to config Django on centos 7
According to this article Here
I installed
sudo yum install python-pip python-devel postgresql-server postgresql-devel postgresql-contrib gcc nginx
After setup PostgreSQL for Django like creating a database, ...
I try installing psycopg2 on virtualenv
pip install django gunicorn psycopg2
but I got this error,
Anyone can help me?
Collecting psycopg2
Using cached psycopg2-2.6.2.tar.gz
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
Complete output from command /usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jk1w8dv1-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2
creating build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/psycopg
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-n0buiow5/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jk1w8dv1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-n0buiow5/psycopg2/
Tested with Python 3:
sudo yum groupinstall "Development Tools"
sudo yum install python3-devel
sudo yum install postgresql-libs
sudo yum install postgresql-devel
[sudo] pip install psycopg2
http://mirror.centos.org/centos/7/os/x86_64/Packages/
Test this
yum install python-psycopg2
You seem to be missing a
sudo yum install postgresql-libs
The installation of postgresql-libs does not help, it actually needs a valid postgresql client. Therefore installing the devel package for CentOS 7 solves it (if it's not an overkill for you).
yum install postgresql-devel
This started happening due to the fact that the pip package stopped shipping with postgresql client binaries, which makes sense since you might want to use a different version in certain scenarios.

lxml installation: error: command 'gcc' failed with exit status 1

I'm trying to install lxml, but I'm getting some sort of error.
# pip install lxml
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting lxml
Using cached lxml-3.6.4.tar.gz
Installing collected packages: lxml
Running setup.py install for lxml ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9YW4Cf/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-bin1bn-record/install-record.txt --single-version-externally-managed --compile:
Building lxml version 3.6.4.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib64
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.6
creating build/lib.linux-x86_64-2.6/lxml
copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/builder.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/cssselect.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/__init__.py -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/sax.py -> build/lib.linux-x86_64-2.6/lxml
creating build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-2.6/lxml/includes
creating build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/clean.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/defs.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/builder.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/diff.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-2.6/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-2.6/lxml/html
creating build/lib.linux-x86_64-2.6/lxml/isoschematron
copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-2.6/lxml/isoschematron
copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-2.6/lxml
copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.6/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-2.6/lxml/includes
creating build/lib.linux-x86_64-2.6/lxml/isoschematron/resources
creating build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/rng
creating build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl
creating build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-2.6/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/src
creating build/temp.linux-x86_64-2.6/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.6 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.6/src/lxml/lxml.etree.o -w
{standard input}: Assembler messages:
{standard input}:224305: Warning: end of file in string; '"' inserted
gcc: Internal error: Killed (program cc1)
Please submit a full bug report.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Compile failed: command 'gcc' failed with exit status 1
creating tmp
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitDjSg3x.c -o tmp/xmlXPathInitDjSg3x.o
cc tmp/xmlXPathInitDjSg3x.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9YW4Cf/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-bin1bn-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9YW4Cf/lxml/
The solution was to run:
yum install python-lxml
My solution was to run:
apk add py3-lxml

error installing lxml on ec2

Having trouble installing lxml on an amazon ec2 instance.
Can you possibly help me figure this out? I think it might be a problem with the way gcc installed based on the wordsize.h issue, but I have no idea.
Any help would be greatly appreciated.
$ sudo pip install lxml
Downloading/unpacking lxml
Downloading lxml-3.3.0.tar.gz (3.4MB): 3.4MB downloaded
Running setup.py (path:/tmp/pip_build_root/lxml/setup.py) egg_info for package lxml
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.3.0.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib64
warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
Running setup.py install for lxml
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.3.0.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib64
building 'lxml.etree' extension
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 -I/tmp/pip_build_root/lxml/src/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
In file included from src/lxml/lxml.etree.c:8:0:
/usr/include/python2.7/pyconfig.h:1:27: fatal error: bits/wordsize.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python27 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-_eECL7-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.3.0.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib64
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/lxml
copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/sax.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/cssselect.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/__init__.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/builder.py -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-2.7/lxml
creating build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-2.7/lxml/includes
creating build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/diff.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/defs.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/clean.py -> build/lib.linux-x86_64-2.7/lxml/html
copying src/lxml/html/builder.py -> build/lib.linux-x86_64-2.7/lxml/html
creating build/lib.linux-x86_64-2.7/lxml/isoschematron
copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-2.7/lxml/isoschematron
copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-2.7/lxml
copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-2.7/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes
creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources
creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng
creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl
creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
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 -I/tmp/pip_build_root/lxml/src/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
In file included from src/lxml/lxml.etree.c:8:0:
/usr/include/python2.7/pyconfig.h:1:27: fatal error: bits/wordsize.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python27 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-_eECL7-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Storing debug log for failure in /root/.pip/pip.log
Looks like it's not finding your platform specific include files. i.e. bits/wordsize.h
Check that you have the following directory:
/usr/include/x86_64-linux-gnu/bits
If it exists try the the following
cd /usr/include
ln -s /usr/include/x86_64-linux-gnu/* .
If the files don't exist try:
sudo apt-get install libc6-dev
If you are using CentOS or Redhat
yum install glibc-devel glibc-headers
If you're trying to install lxml in a Python 3 virtualenv, you'll need to install python34-devel rather than just python-devel:
sudo yum install python34-devel

Error installing psycopg2 in Ubuntu 12.04

I'm having some trouble installing psycopg2 into a virtualenv. Here is the output for pip install psycopg2.
Note 1: I checked a lot of StackOverflow answers and i installed all that *-dev packages suggested. Some hint here?
Note 2: I get same output from python setup.py install on source.
Downloading/unpacking psycopg2
Downloading psycopg2-2.5.1.tar.gz (684kB): 684kB downloaded
Running setup.py egg_info for package psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.1 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x09010A -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.1/server -c psycopg/psycopgmodule.c -o build/temp.linux-i686-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from /usr/include/string.h:642:0,
from /usr/include/python2.7/Python.h:38,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/i386-linux-gnu/bits/string3.h: In function ‘memcpy’:
/usr/include/i386-linux-gnu/bits/string3.h:52:3: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccANjg96.out file, please attach this to your bugreport.
error: command 'gcc' failed with exit status 1
Complete output from command /webapps/sysacad_wrapper/bin/python -c "import setuptools;__file__='/webapps/sysacad_wrapper/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ixowrn-record/install-record.txt --single-version-externally-managed --install-headers /webapps/sysacad_wrapper/include/site/python2.7:
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/psycopg2
copying lib/tz.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/psycopg1.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/_json.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/extras.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/extensions.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/pool.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/errorcodes.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/_range.py -> build/lib.linux-i686-2.7/psycopg2
copying lib/__init__.py -> build/lib.linux-i686-2.7/psycopg2
creating build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-i686-2.7/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-i686-2.7/psycopg2/tests
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-i686-2.7
creating build/temp.linux-i686-2.7/psycopg
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.1 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x09010A -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.1/server -c psycopg/psycopgmodule.c -o build/temp.linux-i686-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from /usr/include/string.h:642:0,
from /usr/include/python2.7/Python.h:38,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/i386-linux-gnu/bits/string3.h: In function ‘memcpy’:
/usr/include/i386-linux-gnu/bits/string3.h:52:3: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccANjg96.out file, please attach this to your bugreport.
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /webapps/sysacad_wrapper/bin/python -c "import setuptools;__file__='/webapps/sysacad_wrapper/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ixowrn-record/install-record.txt --single-version-externally-managed --install-headers /webapps/sysacad_wrapper/include/site/python2.7 failed with error code 1 in /webapps/sysacad_wrapper/build/psycopg2
Traceback (most recent call last):
File "/webapps/sysacad_wrapper/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/webapps/sysacad_wrapper/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
return command.main(args[1:], options)
File "/webapps/sysacad_wrapper/local/lib/python2.7/site-packages/pip/basecommand.py", line 169, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 60: ordinal not in range(128)
I've already solved it. Upgrading gcc to 4.8.2 did the work. Thanks anyway.

Categories

Resources