ERROR: Could not build wheels for roslz4
Python bugs
最近在安装python的rosbag包时出现了诸多问题,特别记录下。
python版本:3.11
系统版本:Windows10 x86_64
使用conda虚拟环境进行包管理。
运行命令
pip3 install roslz4 --extra-index-url
https://rospypi.github.io/simple/
参考:https://www.cnblogs.com/yunhgu/p/15785460.html
终端中出现了以下问题:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://rospypi.github.io/simple/
Collecting roslz4
Using cached https://github.com/rospypi/simple/raw/any/roslz4/roslz4-1.14.3.post2.tar.gz (18 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheel for roslz4 (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for roslz4 (pyproject.toml) did not run successfully.
╰─> [10 lines of output]
running bdist_wheel
running build_py
creating build
creating build\lib.win-amd64-cpython-310\roslz4
copying ros_comm\utilities\roslz4\src\roslz4\__init__.py -> build\lib.win-amd64-cpython-310\roslz4
building '_roslz4' extension
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 roslz4
Failed to build roslz4
ERROR: Could not build wheels for roslz4, which is required to install pyproject.toml-based projects
- 起初在谷歌搜索以为是
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/
这个原因,因为自己也没有安装vs build tools,便尝试安装,但是安装上还无法解决该问题。 - 还尝试了直接下载对应源码,即在
https://rospypi.github.io/simple/
进行下载,但是似乎没有发现本机器对应的包版本,又看见终端出现roslz4-1.14.3.post2.tar.gz
,便去下载该文件,但是运行python setup.py install
命令还是无法安装。 - 然后怀疑是python版本和下载的vs build tools版本不兼容的问题,便搜索对应资料
运行python
进入终端后可查看对应的msc版本。
然后与 https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd 网站中的对应,发现我安装的是vs生成工具是2022年的17.8.6版本,似乎版本过于超前,遂产生改变python版本尝试安装的想法。 - 重建一个3.8python版本的环境,重新运行上述安装命令,直接安装成功,没有任何报错。
故最终原因应该就是:
Python版本不兼容的问题,尽量不要安装较新版本的Python,降低Python版本即可。
我安装的vs生成工具可能没有什么用。
参考:
[1] 版本对应:https://blog.csdn.net/huobanjishijian/article/details/91046070
[2] win10+python3安装rosbag:https://www.cnblogs.com/yunhgu/p/15785460.html