在 RHEL 的虚拟环境中安装 psycopg2 失败
Installing psycopg2 in virtual env on RHEL fails
我已经研究这个好几天了。每次我尝试将 psycopg2 安装到我的 RHEL VPS 上的虚拟环境中时,它都会失败并出现以下错误。任何有线索的人都应该帮忙。谢谢
(pyenv)[root@10 pyenv]# pip install psycopg2==2.5.4
Collecting psycopg2==2.5.4
Using cached psycopg2-2.5.4.tar.gz
/tmp/pip-build-Vn6ET9/psycopg2/setup.py:12: DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately.
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' 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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSI ON="2.5.4 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHA VE_PQFREEMEM=1 -DPG_VERSION_HEX=0x080414 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_B OOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.6 -I. -I/usr/include -I/usr/ include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.6/ psycopg/psycopgmodule.o -Wdeclaration-after-statement
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
Complete output from command /root/pyenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Vn6ET9/psycopg2/setup.py';exec(compile(getatt r(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'ex ec'))" install --record /tmp/pip-9d8Iwo-record/install-record.txt --single-vers ion-externally-managed --compile --install-headers /root/pyenv/include/site/pyt hon2.6:
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/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-2.6/psycopg2
creating build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-2.6/psycop g2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-2.6/psycopg2/te sts
copying tests/test_connection.py -> build/lib.linux-x86_64-2.6/psycopg2/tes ts
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-2.6/psyco pg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-2.6/psycopg2/te sts
copying tests/test_module.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-2.6/psycopg2/t ests
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/psycopg
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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSI ON="2.5.4 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHA VE_PQFREEMEM=1 -DPG_VERSION_HEX=0x080414 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_B OOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.6 -I. -I/usr/include -I/usr/ include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.6/ psycopg/psycopgmodule.o -Wdeclaration-after-statement
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/pyenv/bin/python -c "import setuptools, tokenize;__file__='/ tmp/pip-build-Vn6ET9/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --rec ord /tmp/pip-9d8Iwo-record/install-record.txt --single-version-externally-manag ed --compile --install-headers /root/pyenv/include/site/python2.6" failed with error code 1 in /tmp/pip-build-Vn6ET9/psycopg2
我找到了解决方法。我注意到它在全球范围内成功安装。所以我全局安装了 psycopg2 并使用 --system-site-packages
选项创建了一个新的虚拟环境。然后我使用 -I
选项安装了我的其他包。
希望这对其他人有帮助。
好的。后来我发现我没有安装 gcc
。所以我必须先安装它。在那之后,我可以 pip install psycopg2
。谢谢cel指点。
对我来说,我使用的是 Redhat 8 企业版,我的问题并没有通过安装 gcc 和 gcc-c++ 得到解决。
我通过安装 python3-devel 和 development tools.
解决了这个问题
要使用 yum 管理器在 Redhat 上安装它们,请按照此操作 link
我已经研究这个好几天了。每次我尝试将 psycopg2 安装到我的 RHEL VPS 上的虚拟环境中时,它都会失败并出现以下错误。任何有线索的人都应该帮忙。谢谢
(pyenv)[root@10 pyenv]# pip install psycopg2==2.5.4
Collecting psycopg2==2.5.4
Using cached psycopg2-2.5.4.tar.gz
/tmp/pip-build-Vn6ET9/psycopg2/setup.py:12: DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately.
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' 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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSI ON="2.5.4 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHA VE_PQFREEMEM=1 -DPG_VERSION_HEX=0x080414 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_B OOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.6 -I. -I/usr/include -I/usr/ include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.6/ psycopg/psycopgmodule.o -Wdeclaration-after-statement
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
Complete output from command /root/pyenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Vn6ET9/psycopg2/setup.py';exec(compile(getatt r(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'ex ec'))" install --record /tmp/pip-9d8Iwo-record/install-record.txt --single-vers ion-externally-managed --compile --install-headers /root/pyenv/include/site/pyt hon2.6:
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/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-2.6/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-2.6/psycopg2
creating build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-2.6/psycop g2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-2.6/psycopg2/te sts
copying tests/test_connection.py -> build/lib.linux-x86_64-2.6/psycopg2/tes ts
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-2.6/psyco pg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-2.6/psycopg2/te sts
copying tests/test_module.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-2.6/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-2.6/psycopg2/t ests
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/psycopg
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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSI ON="2.5.4 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHA VE_PQFREEMEM=1 -DPG_VERSION_HEX=0x080414 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_B OOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.6 -I. -I/usr/include -I/usr/ include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.6/ psycopg/psycopgmodule.o -Wdeclaration-after-statement
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/pyenv/bin/python -c "import setuptools, tokenize;__file__='/ tmp/pip-build-Vn6ET9/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --rec ord /tmp/pip-9d8Iwo-record/install-record.txt --single-version-externally-manag ed --compile --install-headers /root/pyenv/include/site/python2.6" failed with error code 1 in /tmp/pip-build-Vn6ET9/psycopg2
我找到了解决方法。我注意到它在全球范围内成功安装。所以我全局安装了 psycopg2 并使用 --system-site-packages
选项创建了一个新的虚拟环境。然后我使用 -I
选项安装了我的其他包。
希望这对其他人有帮助。
好的。后来我发现我没有安装 gcc
。所以我必须先安装它。在那之后,我可以 pip install psycopg2
。谢谢cel指点。
对我来说,我使用的是 Redhat 8 企业版,我的问题并没有通过安装 gcc 和 gcc-c++ 得到解决。
我通过安装 python3-devel 和 development tools.
解决了这个问题要使用 yum 管理器在 Redhat 上安装它们,请按照此操作 link