簡體   English   中英

在OSX 10.7上使用virtualenv中的pip時出現gcc-4.2錯誤

[英]gcc-4.2 error when using pip in virtualenv on OSX 10.7

我正在嘗試在virtualenv環境中安裝psycopg2並且有一點時間。 我想我可能已經搞砸了,因為我安裝了virtualenv,然后升級到Xcode 4。

(my_enviroment)my_users-macbook-2:my_enviroment my_user$ pip install psycopg2

生成此消息:

Downloading/unpacking psycopg2==2.4.2
  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-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.6-intel-2.7/psycopg/psycopgmodule.o
    unable to execute gcc-4.2: No such file or directory
    error: command 'gcc-4.2' failed with exit status 1
    Complete output from command /Users/my_user/my_enviroment/bin/python -c "import setuptools;__file__='/Users/my_user/my_enviroment/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/b8/jflj9btd4rzb80xfmcy_rk140000gn/T/pip-lojVKc-record/install-record.txt --install-headers /Users/my_user/my_enviroment/bin/../include/site/python2.7:
    running install

running build

running build_py

running build_ext

building 'psycopg2._psycopg' extension

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.6-intel-2.7/psycopg/psycopgmodule.o

unable to execute gcc-4.2: No such file or directory

error: command 'gcc-4.2' failed with exit status 1

----------------------------------------
Command /Users/my_user/my_enviroment/bin/python -c "import setuptools;__file__='/Users/my_user/my_enviroment/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/b8/jflj9btd4rzb80xfmcy_rk140000gn/T/pip-lojVKc-record/install-record.txt --install-headers /Users/my_user/my_enviroment/bin/../include/site/python2.7 failed with error code 1
Storing complete log in /Users/my_user/.pip/pip.log

我正在運行OSX 10.7,Python 2.7.2,pip 1.0.2,Xcode 4。

我嘗試了以下解決方案,但沒有成功:

無法使用XCode4在OSX 10.6.7上安裝psycopg2

GCC錯誤:命令'gcc-4.0'失敗,退出狀態為1

有什么想法嗎? 您需要了解哪些其他信息?

同樣的問題。 獅子,最新的xcode。

我下載並安裝了一個新的2.7.2 python和一個virtualenv。

$ which pip
/opt/local/py_env/default/bin/pip
(default)default $ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
(default)default $ which python
/opt/local/py_env/default/bin/python

我補充說:

export CC=/usr/bin/gcc

基於這里的許多答案,為什么pip / easy_install等與Lion有問題。 這解決了編譯問題,但它在鏈接步驟中失敗並出現相同的錯誤:

    /usr/bin/gcc -fno-strict-aliasing -fno-common -dynamic -isysroot /DeveloperSDKs/MacOSX10.6.sdk -g -O2 -DNDEBUG -g -O3 -arch i386 -arch x86_64 PSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x080401 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/Library/PostgreSQL/8.4/include -I/Library/PostgreSQL/8.4/include/postgresql/server -c psycopg/typecast.c -o build/temp.macosx-10.6-intel-2.7/psycopg/typecast.o

gcc-4.2 -bundle -undefined dynamic_lookup -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -arch i386 -arch x86_64 build/temp.macosx-10.6-intel-2.7/psycopg/psycopgmodule.o build/temp.macosx-10.6-intel-2.7/psycopg/green.o build/temp.macosx-10.6-intel-2.7/psycopg/pqpath.o build/temp.macosx-10.6-intel-2.7/psycopg/utils.o build/temp.macosx-10.6-intel-2.7/psycopg/bytes_format.o build/temp.macosx-10.6-intel-2.7/psycopg/connection_int.o build/temp.macosx-10.6-intel-2.7/psycopg/connection_type.o build/temp.macosx-10.6-intel-2.7/psycopg/cursor_int.o build/temp.macosx-10.6-intel-2.7/psycopg/cursor_type.o build/temp.macosx-10.6-intel-2.7/psycopg/lobject_int.o build/temp.macosx-10.6-intel-2.7/psycopg/lobject_type.o build/temp.macosx-10.6-intel-2.7/psycopg/notify_type.o build/temp.macosx-10.6-intel-2.7/psycopg/xid_type.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_asis.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_binary.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_datetime.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_list.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_pboolean.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_pdecimal.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_pint.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_pfloat.o build/temp.macosx-10.6-intel-2.7/psycopg/adapter_qstring.o build/temp.macosx-10.6-intel-2.7/psycopg/microprotocols.o build/temp.macosx-10.6-intel-2.7/psycopg/microprotocols_proto.o build/temp.macosx-10.6-intel-2.7/psycopg/typecast.o -L/Library/PostgreSQL/8.4/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.6-intel-2.7/psycopg2/_psycopg.so

unable to execute gcc-4.2: No such file or directory

1)我認為通過安裝我自己的Python 2.7.2,我可以解決使用CC技巧的需要,因為我安裝了我的python。 為什么不?

2)鏈接器的名稱是否有類似的技巧? 這可能會深入到distutils。

編輯:已解決以下許多博客/ SO建議以下為我工作:回想一下我使用virtualenv運行python 2.7.2 0)添加符號鏈接到/ bin:ln -s / usr / bin / gcc gcc-4.2 1)安裝最新Postgres 。 我從8.4升級到9.1。 沒有卸載8.4,沒有丟失我的數據庫。 2)將/Library/PostgreSQL/9.1/bin添加到$ PATH。 我在我的.profile中做了這個,因為我已經有8.4 / bin,可能出於同樣的原因。 3)pip install psycopg2

我仍然不確定為什么在這種情況下我需要符號鏈接。 也許是因為我沒有從源代碼構建2.7.2。

但是,我的django / postgres應用程序都可以正常工作。 符號鏈接允許我安裝其他包也引用我的virtualenv中的gcc-4.2。

你的錯誤是這樣的:

unable to execute gcc-4.2: No such file or directory

這意味着沒有安裝gcc-4.2

要么降級(或升級)您的GCC版本,要么僅使用gcc命令修改要構建的包。

多一點哈克將ln gcc-4.2gcc命令。

我發現在10.7上安裝PIL的最簡單方法是創建一個從gcc-4.2到gcc的符號鏈接。

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
easy_install pil

我正在使用2.7.7版本的OSV Sierra上安裝mysqlclient並執行以下操作:

xcode-select --install
export CC=gcc
export LDSHARED="gcc -Wl,-x -dynamiclib -undefined dynamic_lookup"
pip install mysqlclient

似乎工作 - gcc-4.2 -bundle似乎來自setuptools build_ext。

嘗試這個

$ sudo apt-get install python-dev

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM