将numpy + pandas安装为setup.py中的依赖项 [英] Install numpy + pandas as dependency in setup.py

查看:130
本文介绍了将numpy + pandas安装为setup.py中的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过setuptools安装numpy + pandas作为setup.py中的依赖项对我不起作用.这与丢失依赖关系无关.如果我通过pip install numpy安装numpy,然后再通过python setup.py develop安装,则一切正常.如果我理解setuptools文档的权利,则首先构建所有软件包,然后再安装.因此,numpy是构建版本,但在构建pandas时未安装.

Installing numpy + pandas via setuptools as dependency in setup.py does not work for me. It is not about missing dependencies. If I install numpy via pip install numpy and afterwards python setup.py develop everything works fine. If I understand the setuptools documentation right, all packages are build first and then installed. So numpy is build, but not installed when pandas is build.

作为一种解决方法,我在setup_requires中添加了numpy.那很好,但显然不是一个很干净的解决方案.

As a workaround I added numpy to my setup_requires. That works fine, but is obviously not a very clean solution.

有人知道通过setuptools安装numpy + pandas的干净解决方案(仅Linux才行)吗?

Does anybody know a clean solution (Linux only is fine) for installing numpy + pandas via setuptools?

更新:

依赖关系是通过

install_requires=['numpy','pandas']

无论我显式添加numpy还是仅添加熊猫,都无济于事.在这两种情况下,都将下载并构建numpy,但是熊猫无法构建,因为找不到某些标头(可能在numpy的安装步骤中安装了这些标头,但未在构建时安装).如果我先安装numpy,则一切正常.我可以重现这100%的内容,并且与我正在从事的项目无关.

It does not make a difference, whether I add numpy explicitly or just add pandas. In both cases numpy will be downloaded and build, but pandas fails to build because some headers (which probably are installed during the install step of numpy, but not while building) cannot be found. If I install numpy first, everything works fine. I can reproduce this 100% and independent of the project I'm working on.

更新2:

这是堆栈跟踪的结尾:

  File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 153, in run
  File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 170, in build_sources
  File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 329, in build_extension_sources
  File "/tmp/easy_install-QMa4ce/pandas-0.14.1/temp/easy_install-f6lreI/numpy-1.9.0/numpy/distutils/command/build_src.py", line 386, in generate_sources
  File "numpy/core/setup.py", line 432, in generate_config_h

  File "numpy/core/setup.py", line 42, in check_types
    entry_points={
  File "numpy/core/setup.py", line 293, in check_types

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

最后的消息肯定是错误的.如果我在运行python setup.py develop之前先执行pip install numpy,则一切正常.在上面的示例中,我在install_requires中只有pandas,而没有numpy.但据我所知,是否显式添加numpy都没有区别.

The message at the end is definitively wrong. If I do a pip install numpy before running python setup.py develop everything works fine. In the example above, I had only pandas in install_requires and no numpy. But as far as I could figure out, it makes no difference whether numpy is added explicitly or not.

推荐答案

请参阅公开问题 https://github.com/numpy/numpy/issues/2434 .

这是numpy中的一个已知错误,因为它与setuptools有关.

This is a known bug in numpy as it relates to setuptools.

如此处所讨论的,使用$ pip install -e .而不是$ python setup.py develop-相同的结果,但是避免了此问题.

As discussed there, use $ pip install -e . rather than $ python setup.py develop -- same result, but avoids this problem.

这篇关于将numpy + pandas安装为setup.py中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆