也许我不了解流程,但是在脚本实际运行之前,我无法设法将依赖项安装到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'
答案 0 :(得分:0)
您import numpy
(和Cython
)在致电setup()
之前。 setup()
没有机会安装任何东西。
对于您而言,setup_requires
无济于事。在运行numpy
之前,先安装Cython
和setup.py
。或重构setup.py
使其不导入numpy
和Cython
。