无法安装模块python pip

时间:2016-03-22 10:54:19

标签: python pip snmp

我是python的新手。我想使用pysnmp模块,所以我尝试用pip安装它,但我从它那里得到错误:

Failed building wheel for pycrypto

我试过多个系统(Ubuntu,Debian和RH),我总是得到同样的错误。我该如何安装pysnmp?或者有没有其他替代方法可以使用snmp与python一起工作?

Shell命令:

sudo -H pip install pysnmp

结果:

...
    configure: creating ./config.status
    config.status: creating src/config.h
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastm                                                                                                 ath.
    building 'Crypto.Hash._MD2' extension
    creating build/temp.linux-x86_64-3.4
    creating build/temp.linux-x86_64-3.4/src
    x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -Wstrict-prototypes -fstack-prot                                                                                                 ector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOUR                                                                                                 CE=2 -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.4m -c                                                                                                  src/MD2.c -o build/temp.linux-x86_64-3.4/src/MD2.o
    src/MD2.c:31:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-                                                                                                 build-7gwchpkq/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(_                                                                                                 _file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp                                                                                                 /pip-6mlabkyq-record/install-record.txt --single-version-externally-managed --co                                                                                                 mpile" failed with error code 1 in /tmp/pip-build-7gwchpkq/pycrypto/

3 个答案:

答案 0 :(得分:3)

  

src/MD2.c:31:20:致命错误:Python.h:没有此类文件或目录

实际错误是你没有python语言的dev文件(找不到python.h)。

所以,安装python-dev

sudo apt-get install  python-dev

答案 1 :(得分:0)

尝试,

x = np.random.random((5, 5)
y = np.random.random(5)

diagonal_y = np.diag(y)
z = np.dot(x, diagonal_y)
np.allclose(z, x * y)  # Will return True

答案 2 :(得分:0)

尝试:

sudo pip install setuptools --upgrade