首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tox、cython和fasttext

tox、cython和fasttext
EN

Stack Overflow用户
提问于 2017-02-22 02:20:05
回答 1查看 1.3K关注 0票数 3

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

我可以让它工作,如果我让毒性使用sitepackages。

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

tox.ini

代码语言:javascript
复制
[tox]
envlist = py27

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

setup.py

代码语言:javascript
复制
from setuptools import setup
setup(
    setup_requires=['cython'],
    install_requires=['cython', 'fasttext'],
)

我从毒性测试中得到的错误是:

代码语言:javascript
复制
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问题吗?或者我错过了一些设置?

EN

回答 1

Stack Overflow用户

发布于 2018-04-29 06:46:14

我可以先用indexserver欺骗tox来安装cython。我们的想法是假装从不同的indexserver安装cython。对于您的情况,它将是:

代码语言:javascript
复制
[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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42375012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档