微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python setuptools选择了不正确的numpy版本

如何解决python setuptools选择了不正确的numpy版本

我有一个带有 setup.py 脚本的 python 包,其依赖关系如下:

    install_requires=[
        'matplotlib<3','numpy>=1.14,<2','Jinja2>=2,<3','pandas>=0.22,<1','biopython>=1.72,!=1.74,<1.78','argcomplete',],python_requires='>3.4,<4',

尝试运行 python3 setup.py install --user 时出现错误

RuntimeError: Python version >= 3.7 required.

这来自

Searching for numpy<2,>=1.14
Reading https://pypi.python.org/simple/numpy/
Downloading https://files.pythonhosted.org/packages/d2/48/f445be426ccd9b2fb64155ac6730c7212358882e589cd3717477d739d9ff/numpy-1.20.1.zip#sha256=3bc63486a870294683980d76ec1e3efc786295ae00128f9ea38e2c6e74d5a60a
Best match: numpy 1.20.1
Processing numpy-1.20.1.zip
Writing /tmp/easy_install-u_dzcets/numpy-1.20.1/setup.cfg
Running numpy-1.20.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-u_dzcets/numpy-1.20.1/egg-dist-tmp-dfrul5ce
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/setuptools/sandBox.py",line 154,in save_modules
    yield saved
  File "/usr/lib/python3/dist-packages/setuptools/sandBox.py",line 195,in setup_context
    yield
  File "/usr/lib/python3/dist-packages/setuptools/sandBox.py",line 250,in run_setup
    _execfile(setup_script,ns)
  File "/usr/lib/python3/dist-packages/setuptools/sandBox.py",line 45,in _execfile
    exec(code,globals,locals)
  File "/tmp/easy_install-u_dzcets/numpy-1.20.1/setup.py",line 30,in <module>
    'matplotlib<3',RuntimeError: Python version >= 3.7 required.

我正在使用 python 3.6.9pip 21.0.1 在干净的测试机器上进行安装。

现在我知道,我可以通过将 numpy 限制为例如来为 python 3.6 解决这个问题<1.19(然后使用 1.18.5),但我无法理解 setuptools 解析为与目标(已安装)python 不兼容的 numpy 版本这一事实。

所以我的问题是如何告诉 setuptoolsinstall_requires 中指定的所有包应该与使用的 python 进一步版本兼容?

是否应该为不同的python版本编写多个依赖规范,而不是依赖setuptools的依赖解析?

感谢您的任何意见

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。