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

FreeBSD 13系统Python 3.10虚拟环境下无法安装Scipy问题求助

问题根因

你遇到的报错属于scipy源码编译失败,FreeBSD平台没有提供scipy的预编译wheel包,且默认系统环境缺少scipy编译必须的Fortran编译器、线性代数基础库,导致构建流程中断。

解决步骤
  • 第一步:安装系统层面依赖(使用root权限执行)
pkg install gcc gfortran openblas lapack pkgconf
  • 第二步:在已激活的虚拟环境中配置编译环境变量,指定依赖库路径和编译器
export BLAS=/usr/local/lib/libopenblas.so
export LAPACK=/usr/local/lib/liblapack.so
export FC=gfortran
export CC=gcc
export CXX=g++
  • 第三步:安装与你现有numpy版本(1.21.4)适配的scipy版本,避免版本不兼容
pip install scipy==1.7.3
  • 第四步:scipy安装完成后,添加参数跳过scipy构建步骤直接安装sklearn
pip install scikit-learn --no-build-isolation

更稳定的备选方案

如果自行编译依然报错,可以直接使用FreeBSD官方预编译的适配包:

  • 用root权限安装系统级py310-scipy包
pkg install py310-scipy
  • 重新创建虚拟环境时添加--system-site-packages参数,即可直接调用系统预安装的scipy,无需额外编译。

内容的提问来源于stack exchange,提问作者Alain Michael Janith Schroter

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 00:15:04