在Ubuntu上通过Buildout安装PyCrypto时,src/config.h: 没有此文件或目录

4 投票
4 回答
3805 浏览
提问于 2025-04-17 05:00

我正在通过 Buildout(使用 easy_install)在一个 Ubuntu 实例上安装 PyCrypto,但遇到了以下错误:

Getting distribution for 'pycrypto>=1.9'.
Running easy_install:
/usr/bin/python "-S" "-c" "import sys,os;p = sys.path[:];import site;sys.path[:] = p;    [sys.modules.pop(k) for k, v in sys.modules.items() if hasattr(v, '__path__') and len(v.__path__)==1 and not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))];from setuptools.command.easy_install import main;main()" "-mUNxd" "/opt/rocktech/buildout/cache/eggs/tmppKIfK7" "-Z" "/opt/rocktech/buildout/cache/download/dist/pycrypto-2.4.tar.gz"
path=/opt/rocktech/buildout/cache/eggs/setuptools-0.6c12dev_r88846-py2.6.egg

Processing pycrypto-2.4.tar.gz
Running pycrypto-2.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dD_8Pu/pycrypto-    2.4/egg-dist-tmp-_d3xDl
error: Setup script exited with error: src/config.h: No such file or directory
An error occurred when trying to install pycrypto 2.4. Look above this message for any     errors that were output by easy_install.
While:
  Installing django.
  Getting distribution for 'pycrypto>=1.9'.
Error: Couldn't install: pycrypto 2.4

有人知道这是什么原因吗?

值得注意的是,我在本地的 Snow Leopard 上也遇到过同样的问题,我通过直接下载代码并手动运行 python manage.py buildpython manage.py install 来解决了这个问题。不过我希望在这里避免这样做,因为我需要在十几台服务器上部署。

4 个回答

1

你还可以下载 pycrypto-2.4.tar.gz,解压它,然后以管理员身份运行:

./configure
python setup.py install

这样一来,pycrypto 就会被安装到 /usr/lib/python2.7/site-packages/Crypto 这个地方。我在使用 'easy_install pysnmp' 的时候测试过这个方法。

1

看起来这是一个未解决的问题。解决方法是使用pip来安装,或者继续使用PyCrypto 2.3版本。https://bugs.launchpad.net/pycrypto/+bug/881130

补充:这个问题在PyCrypto 2.4.1版本中已经修复了。

2

即使使用最新的pycrypto,我还是遇到了这个问题。所以我先运行了 ./configure,这样就生成了src/config.h文件。接下来只需要运行pip、easy_install或者setup.py就可以了……

撰写回答