环境:python3.11;软件:vscode
Collecting pyrfr
Using cached pyrfr-0.9.0.tar.gz (295 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyrfr
Building wheel for pyrfr (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
[<setuptools.extension.Extension('pyrfr._regression') at 0x224560e2d10>, <setuptools.extension.Extension('pyrfr._util') at 0x2245845ffd0>]
Deprecated command line option: -modern. Ignored, this option is now always on.
Deprecated command line option: -py3. Ignored, this option is no longer supported.
.\include\rfr\nodes\k_ary_node.hpp(1) : Warning 401: Nothing known about base class 'k_ary_node_minimal< 2,rfr::splits::binary_split_one_feature_rss_loss< double,double,unsigned int,std::default_random_engine,128 >,double,double,unsigned int,std::default_random_engine >'. Ignored.
.\include\rfr\nodes\k_ary_node.hpp(1) : Warning 401: Maybe you forgot to instantiate 'k_ary_node_minimal< 2,rfr::splits::binary_split_one_feature_rss_loss< double,double,unsigned int,std::default_random_engine,128 >,double,double,unsigned int,std::default_random_engine >' using %template.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyrfr
Running setup.py clean for pyrfr
Failed to build pyrfr
ERROR: Could not build wheels for pyrfr, which is required to install pyproject.toml-based projects
Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
报错原因:由于没有合适的C++版本用来对pyrfr包进行编译,需要安装Microsoft C++ build tools的拓展资源。
解决办法:可以使用离线资源进行安装(csdn上有资源,这种方式使用内存较小),也可以在上面的网址下载,打开官方安装器,进行安装(占据空间较大),选择C++官方工具。
若依然安装失败,可能由于系统无SWIG软件,这里参考Openbox的解决方法:
-
从 SWIG 下载页面 下载 SWIG 的 Windows 版。 点击 All releases ,而后选择 ‘swigwin’ 文件夹。我们推荐安装版本 3.0.12。在下载后解压文件。
-
把 SWIG 文件夹添加到系统路径
完成SWIG的安装以及加入环境变量后,且上述C++环境已经满足,再在终端运行pip install pyrfr;
然后安装成功,可以继续安装smac等包:
pip install smac