【问题标题】:setup_requires does not seem to install dependenciessetup_requires 似乎没有安装依赖项
【发布时间】:2019-05-06 15:29:01
【问题描述】:

也许我不明白流程,但我无法在脚本实际运行之前将依赖项安装到setup.py 文件。我的猜测是,为setup.py 文件提供setup_requires 选项将安装安装文件所需的模块,以便我可以导入它们。这是我的文件:

import os
import numpy
from Cython.Build import cythonize
from setuptools import setup, Extension

# Cython library
ext = [Extension('sp.filters',  # location of the resulting .so
                 ['sp/filters.pyx'],
                 include_dirs=[numpy.get_include()])]


setup(name='Filters',
      description="BlahBlah",
      long_description="BlahBlahBlah",
      packages=['filters'],
      ext_modules=cythonize(ext),
      setup_requires=[
        'cython',
        'numpy,
        'setuptools'
      ],
      install_requires=['numpy',
                        'numba',
                        'scipy',]
)

但我收到以下错误:

ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-uck5sw58/setup.py", line 8, in <module>
        import numpy
    ModuleNotFoundError: No module named 'numpy'

【问题讨论】:

标签: python setuptools setup.py


【解决方案1】:

在致电setup() 之前,您是import numpy(和Cython)。 setup() 没有机会安装任何东西。

在您的情况下,setup_requires 无能为力。在运行setup.py 之前安装numpyCython。或者重构 setup.py 以不导入 numpyCython

【讨论】:

  • 谢谢,我希望 pip install 周围有一些魔法,可以在安装文件中解析以找到 setup_requires 所需的包....
猜你喜欢
  • 2023-04-07
  • 1970-01-01
  • 2019-10-21
  • 2013-08-07
  • 1970-01-01
  • 2020-06-12
  • 2018-03-07
  • 2017-10-05
  • 2023-02-14
相关资源
最近更新 更多