【问题标题】:pip install pubnub throws 'gcc' failed errorpip install pubnub 抛出“gcc”失败错误
【发布时间】:2016-07-29 18:50:25
【问题描述】:

我正在尝试安装 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

谢谢

【问题讨论】:

    标签: python python-2.7 python-3.x pip pubnub


    【解决方案1】:

    您需要安装 Python 的头文件。具体操作方式取决于您的操作系统。

    在 Debian 或 Ubuntu 上,例如,类似

    sudo apt-get install python-dev
    

    应该这样做。

    在 Fedora / CentOS / Red Hat 上,试试

    sudo yum install python-devel
    

    【讨论】:

    • 感谢克里斯的回复。我已经安装了头文件。它仍然给我错误。我正在使用 AWS AMI。
    • @upagna,你是如何安装标题的?
    • 我做了 sudo yum install python-devel 。更新我到目前为止所做的问题
    • @upagna,你机器上的默认 Python 是什么? (试试python --version。)它也是通过yum 安装的吗?
    • 机器上的默认是2.6,我更新到了2.7。
    【解决方案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 软链接并找出它指向的内容

    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
    

    效果不错

    【讨论】:

      猜你喜欢
      • 2019-09-08
      • 2018-09-21
      • 2018-12-26
      • 2020-09-30
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多