2012-07-15 110 views
2

我試圖使用pip將psycopg2安裝到virtualenv中,但似乎存在某種gcc錯誤,我無法得到我的頭。我已經按照其他一些問題的建議安裝了python-dev和libpq-dev。將psycopg2安裝到virtualenv時出現gcc錯誤(Lubuntu 12.04,python 2.7)

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 
+0

你怎麼安裝'gcc'? – 2012-07-15 05:20:09

+0

它與Ubuntu一起安裝。我嘗試重新安裝突觸,但沒有改變任何東西。我需要在virtualenv中設置gcc嗎? – 2012-07-15 05:37:14

回答

1

你需要安裝兩件事情:

  1. sudo apt-get install build-essential
  2. sudo apt-get build-dep python-psycopg2

第一個安裝您需要的必需的構建工具,第二個安裝所需要的依賴於在virtualenv中編譯psycopg2。

+2

感謝您的回覆。我試過你的解決方案,它說build-essentials是最新的:無法找到psycopg2的源碼包。 – 2012-07-15 13:43:40

+0

@danghiskhan嘗試更新的軟件包名稱。 – 2012-08-29 03:53:36

2

編輯您的sources.list文件(通常在etc/apt/sources.list中找到),併爲每個相應的deb行添加一個deb-src行。

http://in.archive.ubuntu.com/ubuntu/ DEB精確主要限制

DEB-SRC http://in.archive.ubuntu.com/ubuntu/精確主要限制#將這個線路

http://in.archive.ubuntu.com/ubuntu/ DEB精確-更新主要限制

DEB-SRC http://in.archive.ubuntu.com/ubuntu/精確-更新主要受限制#添加此行

這兩者之間的區別在於:

  • deb:這些存儲庫包含二進制代碼或預編譯包。 這些存儲庫對於大多數用戶都是必需的。
  • deb-src:這些存儲庫包含 包的源代碼。對開發者有用。

現在試試:

sudo apt-get update 
sudo apt-get build-dep psycopg2 # The name has changed to `psycopg2` from `python-psycopg2` 
相關問題