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

Python3.11环境Fairseq安装失败:缺失version.txt错误修复

解决Conda环境中pip安装fairseq失败的问题

问题场景

在Conda环境中执行pip install fairseq时触发以下错误:

error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [19 lines of output]
Traceback (most recent call last):
File "/opt/conda/envs/beyond_scale_div_coeff/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/opt/conda/envs/beyond_scale_div_coeff/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/beyond_scale_div_coeff/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-nrzuksph/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-nrzuksph/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-nrzuksph/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 313, in run_setup
exec(code, locals())
File "", line 27, in
File "", line 18, in write_version_py
FileNotFoundError: [Errno 2] No such file or directory: 'fairseq/version.txt'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

已尝试操作

  • 更新pip至23.1.2版本
  • 直接执行pip install fairseq

环境信息

  • Python版本:3.11
  • 操作系统:Ubuntu 22.04
  • Pip版本:23.1.2
  • 使用Conda虚拟环境

解决方法

该错误是由于PyPI上的fairseq源码包缺失构建必需的version.txt文件,推荐通过以下两种方式安装:

方法1:从GitHub源码克隆安装

  1. 激活目标Conda环境:
    conda activate beyond_scale_div_coeff
    
  2. 克隆fairseq仓库并进入目录:
    git clone https://github.com/facebookresearch/fairseq.git
    cd fairseq
    
  3. 升级构建工具并以可编辑模式安装:
    pip install --upgrade pip setuptools wheel
    pip install -e .
    

方法2:安装预构建wheel包

若不想从源码构建,可尝试强制安装预编译的wheel包(需确认版本兼容性):

pip install fairseq --only-binary :all:

注:若此方法失败,优先选择方法1

额外注意事项

  • Ubuntu环境下需确保安装了基础编译依赖:
    sudo apt-get update && sudo apt-get install build-essential
    
  • 若需CUDA支持,需提前配置好CUDA环境变量,保证fairseq能检测到CUDA工具链。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 17:53:12