You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Read the Docs构建时安装somoclu出现numpy找不到错误

解决Read the Docs构建时somoclu找不到numpy的问题

问题原因

虽然全局环境已安装numpy,但pip构建somoclu这类需编译的包时,默认启用构建隔离机制——会在仅包含setuptools和wheel的临时环境中执行setup.py,这个临时环境里没有numpy,因此触发ModuleNotFoundError。

解决方案

1. 在requirements.txt中禁用构建隔离

直接在requirements.txt里添加参数,让pip在已安装numpy的当前环境中构建somoclu:

numpy==1.23.3
--no-build-isolation
somoclu==1.7.5.1

注意将numpy放在参数前,确保它先完成安装。

2. 通过Read the Docs配置文件强制指定安装顺序

在项目根目录创建或修改.readthedocs.yaml,明确先安装numpy再安装somoclu:

build:
  os: ubuntu-22.04
  tools:
    python: "3.9"
python:
  install:
    - pip:
        - numpy==1.23.3
        - somoclu==1.7.5.1
    - requirements: docs/requirements.txt  # 保留原有文档依赖的安装

这种方式能绕过构建隔离的限制,严格控制安装顺序。

3. 预安装numpy到构建环境

如果使用Read the Docs旧版配置文件(readthedocs.yml),可在构建前的步骤中先安装numpy:

build:
  pre_install:
    - pip install numpy==1.23.3

内容的提问来源于stack exchange,提问作者shinotakatoshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 07:00:56