我正在制作一个使用tox测试和fasttext Python包的项目。fasttext使用cython。在设置tox环境时,我遇到了一个cython错误:ImportError: No module named Cython.Build。
我可以让它工作,如果我让毒性使用sitepackages。
我已经创建了一个小测试,它产生了相同的错误消息:
tox.ini
[tox]
envlist = py27
[testenv:py27]
# sitepackages=True
commands =
python -m pytest --doctest-modules testinstall.py
deps=
pytest
cython
fasttextsetup.py:
from setuptools import setup
setup(
setup_requires=['cython'],
install_requires=['cython', 'fasttext'],
)我从毒性测试中得到的错误是:
Collecting pytest
Using cached pytest-3.0.6-py2.py3-none-any.whl
Collecting cython
Using cached Cython-0.25.2-cp27-cp27mu-manylinux1_x86_64.whl
Collecting fasttext
Using cached fasttext-0.8.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-8NfmOs/fasttext/setup.py", line 3, in <module>
from Cython.Build import cythonize
ImportError: No module named Cython.Build我发现pip的子依赖项的安装顺序有问题,例如https://github.com/h5py/h5py/issues/535,但我的印象是这个问题已经解决了。
我在setup_requires with Cython?上看到了一个变通方法,但我看不到我的模块可以使用这个变通方法。
这是一个fasttext问题吗?或者我错过了一些设置?
发布于 2018-04-29 06:46:14
我可以先用indexserver欺骗tox来安装cython。我们的想法是假装从不同的indexserver安装cython。对于您的情况,它将是:
[tox]
envlist = py27
# trick to enable pre-installation of Cython
indexserver =
preinstall = https://pypi.python.org/simple
[testenv:py27]
# sitepackages=True
commands =
python -m pytest --doctest-modules testinstall.py
deps=
:preinstall: cython
pytest
fasttext致词:https://github.com/cggh/scikit-allel/blob/v1.1.10/tox.ini
https://stackoverflow.com/questions/42375012
复制相似问题