<p>通过install_requires指令发出numpy安装(Trac#18​​41)</p>

创建于 2012-10-20  ·  39评论  ·  资料来源: numpy/numpy

_trac用户ohe于2011-05-25发行的原始票证http://projects.scipy.org/numpy/ticket/1841 ,已分配给未知对象。

你好,

在virtualenv中,使用python v2.7.1,我无法通过setuptools / distribute的install_requires指令安装numpy。

from setuptools import setup
setup(...
      install_requires=['numpy'],
      ...)

python setup.py install提供了以下回溯:

running install
running bdist_egg
running egg_info
writing requirements to UNKNOWN.egg-info/requires.txt
writing UNKNOWN.egg-info/PKG-INFO
writing top-level names to UNKNOWN.egg-info/top_level.txt
writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build/bdist.macosx-10.6-intel
creating build/bdist.macosx-10.6-intel/egg
creating build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying UNKNOWN.egg-info/PKG-INFO -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying UNKNOWN.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying UNKNOWN.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying UNKNOWN.egg-info/requires.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying UNKNOWN.egg-info/top_level.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/UNKNOWN-0.0.0-py2.7.egg' and adding 'build/bdist.macosx-10.6-intel/egg' to it
removing 'build/bdist.macosx-10.6-intel/egg' (and everything under it)
Processing UNKNOWN-0.0.0-py2.7.egg
Copying UNKNOWN-0.0.0-py2.7.egg to /Users/olivier/tc/karmatest/lib/python2.7/site-packages
Adding UNKNOWN 0.0.0 to easy-install.pth file

Installed /Users/olivier/tc/karmatest/lib/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg
Processing dependencies for UNKNOWN==0.0.0
Searching for numpy
Reading http://pypi.python.org/simple/numpy/
Reading http://numpy.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103
Reading http://numeric.scipy.org
Best match: numpy 1.6.0
Downloading http://sourceforge.net/projects/numpy/files/NumPy/1.6.0/numpy-1.6.0.tar.gz/download
Processing download
Running numpy-1.6.0/setup.py -q bdist_egg --dist-dir /var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/egg-dist-tmp-Zr2lMr
Running from numpy source directory.Warning: distutils distribution has been initialized, it may be too late to add a subpackage commandWarning: distutils distribution has been initialized, it may be too late to add a subpackage fcompilernon-existing path in '/private/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils': 'site.cfg'
Warning: distutils distribution has been initialized, it may be too late to add a subpackage distutilsWarning: distutils distribution has been initialized, it may be too late to add a subpackage testingWarning: distutils distribution has been initialized, it may be too late to add a subpackage f2pyWarning: distutils distribution has been initialized, it may be too late to add an extension _sortWarning: distutils distribution has been initialized, it may be too late to add an extension multiarrayWarning: distutils distribution has been initialized, it may be too late to add an extension umathWarning: distutils distribution has been initialized, it may be too late to add an extension scalarmathWarning: distutils distribution has been initialized, it may be too late to add an extension _dotblasWarning: distutils distribution has been initialized, it may be too late to add an extension umath_testsWarning: distutils distribution has been initialized, it may be too late to add an extension multiarray_testsWarning: distutils distribution has been initialized, it may be too late to add a subpackage coreWarning: distutils distribution has been initialized, it may be too late to add an extension _compiled_baseWarning: distutils distribution has been initialized, it may be too late to add a subpackage libWarning: distutils distribution has been initialized, it may be too late to add a subpackage oldnumericWarning: distutils distribution has been initialized, it may be too late to add an extension _capiWarning: distutils distribution has been initialized, it may be too late to add a subpackage numarrayWarning: distutils distribution has been initialized, it may be too late to add an extension fftpack_liteWarning: distutils distribution has been initialized, it may be too late to add a subpackage fftWarning: distutils distribution has been initialized, it may be too late to add an extension lapack_liteWarning: distutils distribution has been initialized, it may be too late to add a subpackage linalgWarning: distutils distribution has been initialized, it may be too late to add an extension mtrandWarning: distutils distribution has been initialized, it may be too late to add a subpackage randomWarning: distutils distribution has been initialized, it may be too late to add a subpackage maWarning: distutils distribution has been initialized, it may be too late to add a subpackage matrixlibWarning: distutils distribution has been initialized, it may be too late to add a subpackage compatWarning: distutils distribution has been initialized, it may be too late to add a subpackage polynomialWarning: distutils distribution has been initialized, it may be too late to add a subpackage docWarning: distutils distribution has been initialized, it may be too late to add a subpackage numpyCould not locate executable f95
Could not locate executable f90
Could not locate executable f77
Could not locate executable xlf90
Could not locate executable xlf
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable g77
Found executable /usr/local/bin/gfortran
_configtest.c:1: warning: conflicting types for built-in function ‘exp’
_configtest.c:1: warning: conflicting types for built-in function ‘exp’
_configtest.c:1:20: error: Python.h: No such file or directory
_configtest.c:1:20: error: Python.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-//ccLgEqLk.out
_configtest.c:1:20: error: Python.h: No such file or directory
_configtest.c:1:20: error: Python.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-//ccLgEqLk.out
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    install_requires=['numpy']
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 76, in run
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 104, in do_egg_install
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 211, in run
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 427, in easy_install
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 478, in install_item
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 519, in process_distribution
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 563, in resolve
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 799, in best_match
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 811, in obtain
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 446, in easy_install
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 476, in install_item
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 655, in install_eggs
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 930, in build_and_install
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 919, in run_setup
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 62, in run_setup
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 105, in run
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 64, in <lambda>
  File "setup.py", line 196, in <module>

  File "setup.py", line 189, in setup_package

  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/core.py", line 186, in setup
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/olivier/tc/karmatest/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/bdist_egg.py", line 167, in run
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/command/egg_info.py", line 8, in run
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/command/build_src.py", line 152, in run
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/command/build_src.py", line 169, in build_sources
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/command/build_src.py", line 328, in build_extension_sources
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/command/build_src.py", line 385, in generate_sources
  File "/private/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/core/setup.py", line 410, in generate_config_h

  File "/private/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/core/setup.py", line 41, in check_types

  File "/private/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/core/setup.py", line 271, in check_types

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/misc_util.py:251: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/misc_util.py", line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/var/folders/Iy/Iyse1OVUE38-IcPmyTb65E+++TI/-Tmp-/easy_install-W5KwbN/numpy-1.6.0/numpy/distutils/misc_util.py", line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils

我可以在任何virtualenv的内部或外部使用pip install numpyeasy_install numpy安装numpy。

作业系统:Mac OS 10.6.7

00 - Bug Other

最有用的评论

作为遇到此问题的任何人的FYI,使用最新版本的setuptools ,一种解决方法是将NumPy添加到setup_requires 。 我仍然将其保存在install_requires ,因此我的setup.py看起来像:

setup(
...
    setup_requires=["numpy"],
    install_requires=["numpy"],
)

此方法有效,并且仅在Mac OS X和Linux(未在Windows上测试)上安装NumPy一次。

至于为什么我不知道。

所有39条评论

_ @ rgommers写于2011-05-27_

我不确定到底是什么问题,但是可以通过运行先安装numpy然后安装软件包的安装脚本来解决此问题吗? 如果可以避免的话,依靠这些不良记录的setuptools功能不是一个好主意。

如果我不得不猜测,我会说第一次调用setuptools.setup()会调用一堆魔术,为numpy.distutils搞砸了,因此:

Running from numpy source directory.Warning: distutils distribution has been
initialized, it may be too late to add a subpackage commandWarning: distutils
distribution has been initialized, it may be too late to add a subpackage

该警告来自distutils / misc_util.py。

_trac用户ijstokes于2011-06-08_发表

我只是遇到了同样的错误,对我来说,它似乎是由某些依赖关系问题引起的。 如果我将easy_install与其他模块一起重试,则它们将第二次运行。 我最好的猜测是,easy_install会话结束后,某些依赖项才是“可见的”。

伊恩

是否有可能在某个时候解决此问题? 这会导致应有非IHMO的解决方法。 我真的很想达到可以在setup.py的install_requires选项中指定numpy的地步。

当然,如果有人花时间真正理解问题并提交干净的解决方案,这是可能的。 就我个人而言,这不是一件容易的事-应该避免install_requires恕我直言(至少直到pip和easy_install至少在升级软件包时停止升级依赖项为止)。

您可以确认现代distutils / setuptools / pip仍然会出现相同的问题吗?

是的

从我的iPad发送

2013年11月29日晚上7:22,njsmith [email protected]写道:

您能否确认现代仍然出现相同的问题
distutils / setuptools / pip?

-
直接回覆此电子邮件或在上查看
Gi tHubhttps://github.com/numpy/numpy/issues/2434#issuecomment -29485806

刚遇到这个问题,所以可以确认它在那里。 应该优先使用install_requires选项,而不是在不需要时编写自定义安装脚本。

作业系统:Mac 10.8.3

打这个问题来。 没有一个节目停止,但绝对令人讨厌。 尤其是因为从任何方面来看它都不是一个错误,而不是某些用户/环境问题。

我刚刚尝试通过在创建的2.7 virtualenv中安装pandas(使用install_requires )来重现此代码,如下所示:

$ virtualenv --no-site-packages nonumpy
$ source nonumpy/bin/activate
$ cd $PANDAS_DIR
$ pip install cython # needed for pandas
$ python setup.py install

如果有人可以提供一种简单的方法来重现此内容,那将会有所帮助。

我在2.7虚拟环境中也遇到了这个问题。 os ubuntu wheezy

@zethraeus您可以提供一组命令来重现此命令吗(就像上面的评论一样)? 如果我们无法重现该问题,则很难解决。

嗨! 抱歉,花了很长时间,但是这里有一个转播者。

参见: https :

感谢示例@ kejbaly2 ,我现在可以重现它。

尝试使用install_requires和numpy有一个非常相似的问题

这是我如何在Red Hat 6.5上重现错误的方法
https://gist.github.com/necrolyte2/530e9b39dcb0259b69d4

作为遇到此问题的任何人的FYI,使用最新版本的setuptools ,一种解决方法是将NumPy添加到setup_requires 。 我仍然将其保存在install_requires ,因此我的setup.py看起来像:

setup(
...
    setup_requires=["numpy"],
    install_requires=["numpy"],
)

此方法有效,并且仅在Mac OS X和Linux(未在Windows上测试)上安装NumPy一次。

至于为什么我不知道。

我一直试图找出类似的问题,当Numpy的构建通过setup_requires=['Numpy']在Astropy中运行,而Astropy本身作为setup_requires的另一个包装安装时,有时会发生(我称此为“ setupception”)。

我已经将其追溯到这个古老的代码了(但原则上还是有意义的,至少是稍微吗?): https :

大多数情况下,运行Numpy的setup.py时,它将configuration的函数推入numpy.distutils.core.setup的kwarg中。 numpy.distutils.core.setup依次将'configuration'键从设置小程序中弹出,然后在distutils.core设置一些“魔术”全局变量,然后递归调用_itself_ 。 此递归调用的目的是使用distutils机制检查命令行参数中的错误/-帮助。

然后,它调用configuration函数,该setup()函数,现在所有软件包都已完全配置。

这一切都是在肮脏的地方发生的,是Configuration经理偶尔需要调用get_distribution实用程序,以便将内容附加到Distribution对象。 对此的需求是有争议的。 事实上,虽然有代码的某些部分Configuration是认为它应该是能够做到这一点,也有认为,如果已经有一个其他地方Distribution例如连接到distutils.core._setup_distribution则可能出了点问题(因此“有人已在该线程中报告了“ distutils发行版已初始化,现在添加子包可能为时已晚”)。

稍作备份并希望澄清一下-从distutils(或setuptools)运行setup()函数时,它将从setup() kwargs初始化Distribution对象,然后分配结果Distribution到全局变量distutils.core._setup_distribution 。 实际上,它实际上不会清除此变量,因为它假定将在当前Python解释器中运行的是_only_设置。 它不是为设置接收而设计的。 (pip通过从自己的子进程安装每个软件包来安装多个软件包时解决了这个问题和类似问题)。 但是,在其他情况下,例如setup_requires ,根包中可能已经有一个Distribution实例挂在distutils.core._setup_distribution 。 因此,当Numpy的Configuration类试图将_Numpy本身_附加到Distribution对象时,在某些情况下,它可能最终会弄错错误的Distribution 。 由于缺少一些位,这会导致Numpy构建混乱。

从setuptools端和/或Numpy端都有许多可能的解决方法。 我还没有决定最好的方法是什么,但是整个事情绝对是一团糟:)

值得一提的是,setuptools结束时可能采取的一种解决方法是使用setuptools.sandbox.run_setup ,setuptools用于实现setupception的功能,用于在运行安装程序之前/之后保存/恢复所有distutils.core全局变量有问题的脚本。

碰巧的是,我相信当前版本的setuptools可能已经通过在调用子setup.py脚本之前隐藏了原始的distutils.core (将其从sys.modules删除)来解决此问题。 _应该_照顾它。 但是我没有仔细检查。

更新:确认,我上面描述的问题已在大于等于10.0的setuptools中解决(某种程度上是偶然的意外)。

@embray ,这是侦探工作的好地方! (这有点伤了我的头:))

您说对了easy_install -因此我认为get_distribution() -仍然足够相关,以至于我们不应该破坏它。

@rgommers事实是,

@embray听起来不错。 如果您准备好补丁,并且在约2周内未得到审查,请(认真地)踢我一下

setup_requires = [“ numpy”]对我不起作用。 我收到此错误消息:

AttributeError:“模块”对象没有属性“ get_include”。

但是第二次运行“ python setup.py install”解决了该问题。 另请参见http://stackoverflow.com/questions/21605927/why-doesnt-setup-requires-work-properly-for-numpy

我刚遇到@asmaier报告的问题。

就其价值而言,我从未忘记解决此问题的想法,而现在只需要专注于其他事情。 如果有人想偷偷摸摸,我就他们可能去的地方提出了一些高级建议,在此提出了一些意见。

因此,此问题是由于设置了__builtins__.__NUMPY_SETUP__ = True
当您安装需要numpy作为依赖项的依赖项时,setuptools不会重置__NUMPY_SETUP__
看起来您正在尝试在此处设置__NUMPY_SETUP__ = False
https://github.com/numpy/numpy/blob/055056a3108ab19883e50ac125ab9974823498c7/numpy/distutils/misc_util.py#L2195
但此代码从未到达,因为前一行的返回值...

实际上,我相信整个isbootstrapping函数在这里滥用/滥用__builtins__的方式会在您将numpy作为依赖项并且具有以numpy作为依赖项的依赖项时中断。

@JensTimmerman我怀疑这也与https://github.com/matplotlib/matplotlib/issues/6928有关,

欢迎提供任何解决此问题的正确方法的建议。

@rgommers有何想法?

看起来您正在尝试在此处设置NUMPY_SETUP = False
https://github.com/numpy/numpy/blob/055056a3108ab19883e50ac125ab9974823498c7/numpy/distutils/misc_util.py#L2195
但此代码从未到达,因为前一行的返回值...

is_bootstrapping函数不会在看起来像的任何地方使用,因此无关紧要。

实际上,我相信整个isbootstrapping函数在这里滥用/滥用内置函数,这种方式在您将numpy作为依赖项并且具有以numpy作为依赖项的依赖项时会中断。

__builtins__的唯一用途是在此处的主要setup.py

这很丑陋,但也很难以更强大的方式编写。 我目前的猜测是,如果存在问题,在某些情况下只会以setup_requires='numpy' ,而不会以install_requires 。 它们之间的区别在于前者调用setuptools因为pip尚不知道如何处理它。 在Scipy中,我们确实使用setup_requires='numpy' ,并且从未遇到过此问题。 因此,可能还有matplotlib安装脚本中的时髦功能。

通过https://github.com/numpy/numpy/issues/2434#issuecomment -77898051再次阅读,这似乎很好地描述了问题的原因,我认为这与__NUMPY_SETUP__没有任何关系。

编辑:或者也许在某些情况下可以,但是很难用另一种方式来处理。 通常,这里没有问题,因为pip设法以一种完全隔离的方式来构建/安装东西。

通过在setup.py的末尾使用del builtins.__NUMPY_SETUP__来证明这个理论是对还是错都不应该太难。

在gh-7956中尝试了一下

万一https://github.com/numpy/numpy/issues/2434#issuecomment -49156521中的要点在某个时候消失了,这里有一个复制此问题的方法:

cd /tmp

cat > ./setup.py <<DELIM
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: "Chris Ward" <[email protected]>

from setuptools import setup

default_setup = dict(
    name='numpy_install_test',
    description='https://github.com/numpy/numpy/issues/2434',
    provides=['numpy_install_test'],
    install_requires=['pandas'],
    requires=['pandas'],
    license='GPLv3',
    author='Chris Ward',
    author_email='[email protected]',
)   

setup(**default_setup)

DELIM


virtualenv --no-site-packages ~/virtenvs/nonumpy
source ~/virtenvs/nonumpy/bin/activate
python setup.py install

难以使用pip install -R requirements.txt在python2.7.16中安装熊猫

https://files.pythonhosted.org/packages/b2/4c/b6f966ac91c5670ba4ef0b0b5613b5379e3c7abdfad4e7b89a87d73bae13/pandas-0.24.2.tar.gz(11.8MB
来自命令python setup.py egg_info的完整输出:
追溯(最近一次通话):
文件““,第1行,在
文件“ /tmp/pip-install-WznqHc/pandas/setup.py”,行746,在
setuptools_kwargs)安装程序中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/__init__.py”,第144行_install_setup_requires(attrs)_install_setup_requires中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/__init__.py”,第139行dist.fetch_build_eggs(dist.setup_requires)fetch_build_eggs中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/dist.py”,行724replace_conflicting =是,解析文件“ /usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py”,第782行replace_conflicting = replace_conflicting文件“ /usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py”,行1065,在best_match中返回self.obtain(要求,安装程序)在获得的文件“ /usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py”中,行1077返回安装程序(要求)文件“ /usr/local/lib/python2.7/site-packages/setuptools/dist.py”,行791,位于fetch_build_egg中返回cmd.easy_install(req)在easy_install中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py”,第679行返回self.install_item(spec,dist.location,tmpdir,deps)在install_item中的第705行,文件“ /usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py”dists = self.install_eggs(规格,下载,tmpdir)在install_eggs中的第890行,文件“ /usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py”返回self.build_and_install(setup_script,setup_base)在build_and_install中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py”,行1158self.run_setup(setup_script,setup_base,args)在run_setup中的第1144行,文件“ /usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py”run_setup(setup_script,args)在run_setup中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,第253行提高__exit__中的文件“ /usr/local/lib/python2.7/contextlib.py”,第35行self.gen.throw(类型,值,追溯)在setup_context中的第195行中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”__exit__中的文件“ /usr/local/lib/python2.7/contextlib.py”,第35行self.gen.throw(类型,值,追溯)在save_modules中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,行166saved_exc.resume()简历中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,第141行6.reraise(type,exc,self._tb)在save_modules中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,第154行节省产量在setup_context中的第195行中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”在run_setup中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,第250行_execfile(setup_script,ns)_execfile中的文件“ /usr/local/lib/python2.7/site-packages/setuptools/sandbox.py”,第45行exec(代码,全局变量,本地变量)**文件“ /tmp/easy_install-2M8B7z/numpy-1.17.0rc1/setup.py”,第31行,在

**RuntimeError: Python version >= 3.5 required.**

不知道为什么要查找不支持python2的numpy-1.17.0rc1

任何帮助,将不胜感激,谢谢

请分享您的requirements.txt

需求文件包含:

烧瓶== 1.0.2
flask-jwt == 0.3.2
flask-script == 2.0.6
flask-scrypt == 0.1.3.6
PyJWT <1.5.0
眨眼== 1.4
电话号码== 8.9.12
侧翼== 0.9.0
bugsnag == 3.4.3
pickledb == 0.7.2
要求== 2.19.1
python-dateutil == 2.8.0
gunicorn == 19.9.0
gevent == 1.3.6
webargs == 4.0.0
ply == 3.10
bson == 0.5.7
芹菜== 4.2.1
redis == 3.2.1
雷迪斯
numpy == 1.16.4

最后管理它以将numpy保留在需求文件中,并在以后安装熊猫

在Docker中运行命令:

运行pip安装https://github.com/pydata/pandas/releases/download/v0.24.2/pandas-0.24.2.tar.gz

但是,现在编译存在另一个问题,即您需要安装cython来编译熊猫。

错误:

例外:找不到Cython生成的文件'pandas / io / sas / sas.c'。
Cython需要从开发分支编译熊猫。
请安装Cython或下载熊猫发布包。

任何想法?

与此问题无关,该问题与在setup.py使用install_requires setup.py 。 请打开新一期。 您真的需要从源代码安装熊猫吗? 为什么不pip install pandas==0.24.2呢?

是的,我将在pandas库中打开此问题。 但是,由于您无法直接安装熊猫numPy,因此我之前提到的与numPy有关的帖子已正确安装在docker env下的Python2.7上。
为什么不pip install pandas == 0.24.2? 因为当我在docker下运行它时会说。

例外:找不到Cython生成的文件“ pandas / msgpack.c”。
Cython需要从开发分支编译熊猫。
请安装Cython或下载熊猫发布包。

所以我需要使用要从tarball安装的熊猫发行版

闭幕。 我认为python世界正从setup_requires移到requirements.txtpyproject.toml 。 下面的变通办法是针对仍想使用setup_requires

setup(
...
    setup_requires=["numpy"],
    install_requires=["numpy"],
)

至于试图在python2上安装numpy的@omeryounus ,这是一个与此问题无关的单独问题。 一些用户报告说,将pip和setuptools升级到最新版本可以解决该问题。

如果还有更多要讨论的地方,请重新打开setup_requires

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

qualiaa picture qualiaa  ·  3评论

toddrjen picture toddrjen  ·  4评论

kevinzhai80 picture kevinzhai80  ·  4评论

ghost picture ghost  ·  4评论

keithbriggs picture keithbriggs  ·  3评论