将psycopg2安装到virtualenv中时出现Gcc错误(Lubuntu 12.04,python 2.7) [英] Gcc error when installing psycopg2 into a virtualenv (Lubuntu 12.04, python 2.7)
问题描述
我正在尝试使用pip将psycopg2安装到virtualenv中,但是似乎出现了某种gcc错误,我无法理解。我已经按照其他一些问题的建议安装了python-dev和libpq-dev。
I'm trying to install psycopg2 into a virtualenv using pip but there seems to be some kind of gcc error that I can't get my head around. I've installed python-dev and libpq-dev as suggested by some other questions.
pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
no previously-included directories found matching 'doc/src/_build'
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.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -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
gcc: error trying to exec 'as': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
Complete output from command /home/mdang/Dropbox/WebDev/ideas/venv/bin/python -c "import setuptools;__file__='/home/mdang/Dropbox/WebDev/ideas/venv/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-SBgH20-record/install-record.txt --install-headers /home/mdang/Dropbox/WebDev/ideas/venv/include/site/python2.7:
running install
running build
running build_py
running build_ext
building 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -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
gcc: error trying to exec 'as': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/mdang/Dropbox/WebDev/ideas/venv/bin/python -c "import setuptools;__file__='/home/mdang/Dropbox/WebDev/ideas/venv/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-SBgH20-record/install-record.txt --install-headers /home/mdang/Dropbox/WebDev/ideas/venv/include/site/python2.7 failed with error code 1 in /home/mdang/Dropbox/WebDev/ideas/venv/build/psycopg2
Storing complete log in /home/mdang/.pip/pip.log
推荐答案
编辑您的sources.list文件(标准盟友在 etc / apt / sources.list
中找到),并为每个相应的<$ c $添加一个 deb-src
c> deb 行。
Edit your sources.list file (normally found in etc/apt/sources.list
) and add a deb-src
for each corresponding deb
line.
deb http://in.archive.ubuntu.com/ubuntu/ 精确主限制
deb-src http://in.archive.ubuntu.com/ubuntu/ 精确主限制 #添加此行
deb-src http://in.archive.ubuntu.com/ubuntu/ precise main restricted #Add this line
deb http://in.archive.ubuntu.com/ubuntu/ 精确更新主要限制
deb http://in.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://in.archive.ubuntu.com/ubuntu/ 精确更新主要受限#添加此行
deb-src http://in.archive.ubuntu.com/ubuntu/ precise-updates main restricted #Add this line
两者之间的区别:
-
deb
:这些存储库包含二进制文件或PR编译的软件包。
大多数用户都需要这些存储库。 -
deb-src
:这些存储库包含$ b的源代码$ b包。对开发人员有用。
deb
: These repositories contain binaries or precompiled packages. These repositories are required for most users.deb-src
: These repositories contain the source code of the packages. Useful for developers.
现在尝试:
sudo apt-get update
sudo apt-get build-dep psycopg2 # The name has changed to `psycopg2` from `python-psycopg2`
这篇关于将psycopg2安装到virtualenv中时出现Gcc错误(Lubuntu 12.04,python 2.7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!