在 pyenv 中安装 Fabric 错误

Posted

技术标签:

【中文标题】在 pyenv 中安装 Fabric 错误【英文标题】:Install Fabric error in pyenv 【发布时间】:2016-07-04 07:55:09 【问题描述】:

当我在 AWS Ubuntu 中生产我的项目时,我想使用 Fabric。当我阅读 Fabric 时,它需要 python 2.5~2.7,所以我在 Mac OS X 上创建了 Python virtualenv:

pyenv virtualenv 2.7.5 fabric
mkdir fabric

然后我运行pip install fabric

(fabric)fabric $ pip install fabric

但它有 2 个错误

Collecting fabric

[...]

configure: creating ./config.status
config.status: creating src/config.h
building 'Crypto.PublicKey._fastmath' extension
creating build/temp.macosx-10.11-x86_64-2.7
creating build/temp.macosx-10.11-x86_64-2.7/src
clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c     
src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0     is always false [-Wtautological-compare]
                      else if (result < 0)
                               ~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                      else if (result < 0)
                               ~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1


------------------------------------------------------

Failed building wheel for pycrypto
Running setup.py clean for pycrypto
Failed to build pycrypto

Installing collected packages: pycrypto, paramiko, fabric
Running setup.py install for pycrypto ... error

Complete output from command /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto:

clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                        else if (result < 0)
                                 ~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                        else if (result < 0)
                                 ~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

-------------------------------------------------------

Command "/Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto" failed with error code 1 in /private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/

有人告诉我“你应该安装 pycrpto”,所以我安装了 pycrpto

pip install pycrpto

但是当我pip install fabric 时它有同样的错误。我找到了这个解决方案link,所以我运行:

brew install gmp
export LIBRARY_PATH=/usr/local/lib
pip install pycrypto

但它有同样的错误,第二个解决方案是link

$ bunzip2 gmp-5.0.5.tar.bz2

但它还有另一个错误:

bunzip2: Can't open input file gmp-5.0.5.tar.bz2: No such file or directory. 

我不明白为什么 Fabric 无法安装...

【问题讨论】:

可能不是核心问题,但请注意'pycrpto' != 'pycrypto' 嗯....谢谢!但是pip install pycrypto 也不起作用 哦....我的错误...fabric可以安装2.5 &lt; fabric ver &lt; 2.7我使用pyenv 2.6.7我解决了我的问题! 【参考方案1】:

这是 Python pyenv#273。

你可以通过修补_sysconfigdata.py来修复它:

$ export p=/Users/andrei/.pyenv/versions/2.7.6
$ sed -i -e "s#python.exe#$p/bin/python2.7#g" "$p/lib/python2.7/_sysconfigdata.py"

【讨论】:

以上是关于在 pyenv 中安装 Fabric 错误的主要内容,如果未能解决你的问题,请参考以下文章

在RHEL上的虚拟环境中安装psycopg2失败

在eclipse中安装go编辑器阅读fabric代码

使用 pyenv 可以在一个系统中安装多个python版本

如何在 Service Fabric 中安装批处理文件

Fabric1.4 在自己项目中安装区块链浏览器blockchain-explorer

Fabric1.4 在自己项目中安装区块链浏览器blockchain-explorer