3

我正在制作一个tox测试和使用fasttextPython 包的项目。fasttext使用赛通。我在 tox 环境设置过程中遇到了 cython 错误:ImportError: No module named Cython.Build.

如果我让 tox 使用站点包,我可以让它工作。

我创建了一个产生相同错误消息的小测试:

tox.ini

[tox]
envlist = py27

[testenv:py27]
# sitepackages=True
commands = 
    python -m pytest --doctest-modules testinstall.py
deps=
    pytest
    cython
    fasttext

setup.py

from setuptools import setup
setup(
    setup_requires=['cython'],
    install_requires=['cython', 'fasttext'],
)

我从 tox 得到的错误是:

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 中看到了 Cython 的解决方法?但我看不到我的模块可以使用该解决方法。

这是一个fasttext问题吗?或者我缺少一些设置?

4

1 回答 1

3

我可以欺骗 tox 先使用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

于 2018-04-28T22:46:14.020 回答