我正在尝试安装pubnub库,当我执行pip install pubnub时出现错误
Compiling support for Intel AES instructions
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DLTC_NO_ASM -DHAVE_CPUID_H -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.linux-x86_64-2.7/src/MD2.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/src/MD2.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_MD2.so
/usr/bin/ld: cannot find -lpython2.7
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
这是我遵循的步骤
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python27 get-pip.py
sudo yum install git
git clone https://github.com/pubnub/python && cd python/python
sudo update-alternatives --config python
sudo yum install python-devel
sudo yum install gcc
由于
答案 0 :(得分:3)
您需要安装Python的头文件。如何操作取决于您的操作系统。
在Debian或Ubuntu上,例如
sudo apt-get install python-dev
应该这样做。
在Fedora / CentOS / Red Hat上,试试
sudo yum install python-devel
答案 1 :(得分:2)
对此的解决方案,我必须遵循这些步骤
ld -lpython2.7 --verbose
attempt to open /usr/x86_64-amazon-linux/lib64/libpython2.7.so failed
attempt to open /usr/x86_64-amazon-linux/lib64/libpython2.7.a failed
attempt to open /usr/local/lib64/libpython2.7.so failed
attempt to open /usr/local/lib64/libpython2.7.a failed
attempt to open /lib64/libpython2.7.so failed
attempt to open /lib64/libpython2.7.a failed
attempt to open /usr/lib64/libpython2.7.so failed
attempt to open /usr/lib64/libpython2.7.a failed
attempt to open /usr/x86_64-amazon-linux/lib/libpython2.7.so failed
attempt to open /usr/x86_64-amazon-linux/lib/libpython2.7.a failed
attempt to open /usr/lib64/libpython2.7.so failed
attempt to open /usr/lib64/libpython2.7.a failed
attempt to open /usr/local/lib/libpython2.7.so failed
attempt to open /usr/local/lib/libpython2.7.a failed
attempt to open /lib/libpython2.7.so failed
attempt to open /lib/libpython2.7.a failed
attempt to open /usr/lib/libpython2.7.so failed
attempt to open /usr/lib/libpython2.7.a failed
检查用于python的ldconfig softlink并找出它指向
的内容ldconfig -p | grep python2.7
libpython2.7.so.1.0 (libc6,x86-64) => /usr/lib64/libpython2.7.so.1.0
这表明它正在寻找错误的软链接,我改变了像这样的软链接
sudo ln -s /usr/lib64/libpython2.7.so.1.0 /usr/lib64/libpython2.7.so
然后必须像这样运行pip
sudo /usr/local/bin/pip install pubnub -- Location of pip installed
工作得很好