2

pipを使用してpsycopg2をvirtualenvにインストールしようとしていますが、頭を動かすことができない何らかのgccエラーがあるようです。他のいくつかの質問で示唆されているように、python-devとlibpq-devをインストールしました。

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
4

2 に答える 2

2

sources.list ファイル (通常は にあります) を編集し、対応する各行に foretc/apt/sources.listを追加します。deb-srcdeb

deb http://in.archive.ubuntu.com/ubuntu/正確な主な制限付き

deb-src http://in.archive.ubuntu.com/ubuntu/正確な主な制限#この行を追加

deb http://in.archive.ubuntu.com/ubuntu/正確なアップデート メイン制限付き

deb-src http://in.archive.ubuntu.com/ubuntu/ precision -updates main limited #この行を追加

2つの違い:

  • deb: これらのリポジトリには、バイナリまたはプリコンパイル済みパッケージが含まれています。これらのリポジトリは、ほとんどのユーザーに必要です。
  • deb-src: これらのリポジトリには、パッケージのソース コードが含まれています。開発者にとって便利です。

今試してみてください:

sudo apt-get update
sudo apt-get build-dep psycopg2  # The name has changed to `psycopg2` from `python-psycopg2` 
于 2013-01-18T04:39:23.010 に答える
1

次の 2 つをインストールする必要があります。

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

1 つ目は必要なビルド ツールをインストールし、2 つ目は virtualenv 内で psycopg2 をコンパイルするために必要な依存関係をインストールします。

于 2012-07-15T06:10:36.530 に答える