setup_requires似乎没有安装依赖项

时间:2019-05-06 15:29:02

标签: python setuptools setup.py

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

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'

1 个答案:

答案 0 :(得分:0)

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

对于您而言,setup_requires无济于事。在运行numpy之前,先安装Cythonsetup.py。或重构setup.py使其不导入numpyCython