在Anaconda Spyder中安装petitRADTRANS失败的解决求助
问题背景
我通过Anaconda安装了Spyder,想要使用petitRADTRANS包。按照指引,已在Spyder的IPython控制台和Anaconda Prompt中执行pip install numpy meson-python ninja并成功安装,随后执行pip install petitRADTRANS --no-build-isolation却持续报错:
WARNING: Failed to activate VS environment: Could not parse vswhere.exe output
Project name: petitRADTRANS
Project version: 3.2.0
..\meson.build:3:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']] The following exception(s) were encountered: Running `icl ""` gave "[WinError 2] The system cannot find the file specified" Running `cl /?` gave "[WinError 2] The system cannot find the file specified" Running `cc --version` gave "[WinError 2] The system cannot find the file specified" Running `gcc --version` gave "[WinError 2] The system cannot find the file specified" Running `clang --version` gave "[WinError 2] The system cannot find the file specified" Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified" Running `pgcc --version` gave "[WinError 2] The system cannot find the file specified"
使用conda install petitRADTRANS时,系统无法识别该包。已安装Visual Studio,请问该如何解决?
解决步骤
1. 补全Visual Studio编译组件
打开Visual Studio Installer,检查是否安装了**"Desktop development with C++"**工作负载,必须包含以下核心组件:
- MSVC v14x - VS 20xx C++ x64/x86 build tools
- Windows 10/11 SDK
- C++ CMake tools for Windows
若未安装,勾选对应选项后点击"修改"完成安装。
2. 配置Anaconda环境指向MSVC编译器
打开Anaconda Prompt,先激活你的目标环境(替换为你的环境名,比如base):
conda activate base
临时设置环境变量让meson识别MSVC:
set CC=cl set CXX=cl
若需要永久配置到conda环境,执行:
conda config --set env_vars.CC cl conda config --set env_vars.CXX cl
3. 备选方案:使用Anaconda自带的MinGW编译器
如果MSVC仍无法被识别,可安装Anaconda提供的gcc编译器:
conda install -c conda-forge mingw-w64
设置环境变量指向MinGW的编译器:
set CC=gcc set CXX=g++
4. 重新执行安装命令
在配置好编译器的Anaconda Prompt中,重新运行:
pip install petitRADTRANS --no-build-isolation
5. 验证安装结果
打开Spyder,在IPython控制台输入以下代码验证:
import petitRADTRANS print(petitRADTRANS.__version__)
若成功打印版本号,说明安装完成。
内容的提问来源于stack exchange,提问作者kyra

