【问题标题】:ImportError: No module named 'Cython' when installing requirements on readthedocs serverImportError:在 readthedocs 服务器上安装要求时没有名为“Cython”的模块
【发布时间】:2018-05-15 20:41:51
【问题描述】:

我想使用扩展来自动生成代码 sn-ps 中示例的输出以用于 readthedocs。我找到了一个执行此操作的模块 sphinx-autorun。但是,当我尝试安装我的包所需的所有模块时(在 readthedocs 的要求中),我在 readthedocs 的构建日志中收到错误,即:

Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-tsfmsady/clustertree/setup.py", line 6, in <module>
    from Cython.Build import cythonize
ImportError: No module named 'Cython' 

关于如何解决此问题的任何提示?我设置了以下选项:

【问题讨论】:

  • 你的需求文件中有 cython 吗?
  • 您可能还想在 readthedocs 上尝试基于 conda 的构建,特别是如果您的包有需要编译的依赖项
  • 听起来好像有些东西没有安装在您本地环境中安装的 RTD 上。尝试将您的 repo 克隆到一个干净的结帐中,然后重复 RTD 调用以构建文档的命令。您的 requirements.txt 文件中可能还有一些您希望在 RTD 中出现但实际上没有的内容。
  • @ngoldbaum 是的,感谢您的提示 :)
  • @StevePiercy 好主意,我会在基于 conda 的构建之后尝试:)

标签: cython python-sphinx read-the-docs


【解决方案1】:

基于 conda 的构建对我有用。

您可以将 readthedocs.yml 放在 repo 的根文件夹中(而不是您的 docs 文件夹):

requirements_file:
  docs/requirements.txt

conda:
    file: environment.yml

我的 conda environment.yml:

channels:
- conda-forge
- bioconda
- r
- jkroes
dependencies:
- cython
- python=3.6
- numpy
- pandas
- sphinx-autorun=1.1.0=py36h5809654_0

你甚至可以在 conda yaml 中有一个 pip 部分:

channels:
- conda-forge
- bioconda
- r
- jkroes
dependencies:
- cython
- python=3.6
- numpy
- pandas
- pip:
    - clustertree
    - pyranges
    - sphinx_autorun_ebs
    - pyrle
    - sorted_nearest

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    • 2012-01-13
    • 2017-10-14
    • 2015-10-04
    • 2016-10-26
    • 1970-01-01
    • 2016-12-07
    相关资源
    最近更新 更多