1.背景
计划使用NI veristand
的python
依赖包,但是在安装的过程中始终报错。
环境:
python: 3.10.1
2.错误描述
主要的错误其实有两点:
- wheel 的问题,这个是因为没有安装
wheel
的包的问题,直接pip install wheel
即可
- 还有一个问题是关于
.net
的,在安装报错的提示中,关键描述如下:
2.1 错误关键语句_1
Building wheels for collected packages: pythonnet
Building wheel for pythonnet (setup.py) ... error
ERROR: Command errored out with exit status 1:
2.2 错误关键语句_2
ERROR: Failed building wheel for pythonnet
Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
ERROR: Command errored out with exit status 1:
2.3 错误关键语句_3
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option --single-version-externally-managed not recognized
3.原因
1.windows
环境下,很多东西需要.net
支持,但是在安装pythonnet
的包的过程中,经常会出现其与python
版本不匹配的问题
2.再次重复:凡是需要.net
的地方,核心的问题点就是在于解决pythonnet
与python
版本匹配的问题
4.解决问题
1.打开官网:pythonnet,可以看到当前版本并不支持python 3.10
2.点击链接:Unofficial Windows Binaries for Python Extension Packages
3.由于仍然没有匹配python3.10
的版本,故此点击下载pythonnet-2.5.2-cp39-cp39-win_amd64.whl(for 64-bit python version)
4.放置在路径C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\pythonnet
下(windows路径一般如上)
5.在命令运行行窗口
输入pip install C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\pythonnet\pythonnet-2.5.2-cp39-cp39-win_amd64.whl
6.由于pythonnet
版本不匹配python 3.10.1
,会报错如下:
7.将刚下载的文件修改名称
// 修改之前
pythonnet-2.5.2-cp39-cp39-win_amd64.whl
// 修改之后
pythonnet-2.5.2-cp310-none-any.whl
8.再次在命令行窗口
运行pip install C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\pythonnet\pythonnet-2.5.2-cp310-none-any.whl
,即可安装成功
5.总结
1.pythonnet
版本不匹配当前python
版本
2.下载最新的pythonnet
,然后修改名称使其与python
版本一致
3.使用全路径安装即可成功
6.参考链接
1.How to fix error during pythonnet installation
2.pythonnet 2.5.2
3.Unofficial Windows Binaries for Python Extension Packages
4.python解决Failed building wheel for XXX
5.pip documentation v21.3.1