「已解决」mujoco py install error - fatal error: GL/osmesa.h: No such file or directory

用户在安装mujoco相关库时遇到编译错误,因GL/osmesa.h文件未找到。解决方法是通过`sudoapt-getinstalllibosmesa6-dev`来安装所需的开发库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述

安装mujoco200和mujoco-py时遇到报错

/tmp/pip-install-17okd8wq/mujoco-py_12b8907c86c0458dab4f02eedf9b2ad1/mujoco_py/gl/osmesashim.c:1:10: fatal error: GL/osmesa.h: No such file or directory
        1 | #include <GL/osmesa.h>
          |          ^~~~~~~~~~~~~
    compilation terminated.
    error: command '/usr/bin/gcc' failed with exit code 1

解决办法

sudo apt-get install libosmesa6-dev
Collecting pysqlite3 Using cached pysqlite3-0.5.4.tar.gz (40 kB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: pysqlite3 Building wheel for pysqlite3 (setup.py): started Building wheel for pysqlite3 (setup.py): finished with status 'error' Running setup.py clean for pysqlite3 Failed to build pysqlite3 DEPRECATION: Building 'pysqlite3' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'pysqlite3'. Discussion can be found at https://github.com/pypa/pip/issues/6334 error: subprocess-exited-with-error python setup.py bdist_wheel did not run successfully. exit code: 1 [27 lines of output] I:\91-agi09-do\02code\env3114\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: zlib/libpng License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-311\pysqlite3 copying pysqlite3\dbapi2.py -> build\lib.win-amd64-cpython-311\pysqlite3 copying pysqlite3\__init__.py -> build\lib.win-amd64-cpython-311\pysqlite3 running build_ext Builds a C extension linking against libsqlite3 library building 'pysqlite3._sqlite3' extension creating build\temp.win-amd64-cpython-311\Release\src "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -II:\91-agi09-do\02code\env3114\include -IC:\Python3114\include -IC:\Python3114\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tcsrc\blob.c /Fobuild\temp.win-amd64-cpython-311\Release\src\blob.obj blob.c C:\Users\Administrator\AppData\Local\Temp\pip-install-sevcsc1s\pysqlite3_9ae8b19f2d3b487da835e25ebab5786b\src\blob.h(4): fatal error C1083: 无法打开包括文件: “sqlite3.h”: No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pysqlite3 ERROR: Failed to build installable wheels for some pyproject.toml based projects (pysqlite3)
最新发布
07-17
下面是出现的报错× Building wheel for SharedArray (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [9 lines of output] running bdist_wheel running build running build_ext building 'SharedArray' extension creating build\temp.win-amd64-cpython-38\Release\src "D:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\LinRongqing\AppData\Local\Temp\pip-build-env-6gok3aov\overlay\Lib\site-packages\numpy\core\include -ID:\anaconda3\envs\ pytorch\include -ID:\anaconda3\envs\pytorch\Include "-ID:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808 \include" "-ID:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\ include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\incl ude\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tc.\src\map_owner.c /Fobuild\temp.win-amd64-cpython-38\Release\.\src\map_owner.obj map_owner.c .\src\map_owner.c(19): fatal error C1083: 无法打开包括文件: “sys/mman.h”: No such file or directory error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for SharedArray Failed to build SharedArray ERROR: Could not build wheels for SharedArray, which is required to install pyproject.toml-based projects
03-12
<think>好的,用户的问题是关于在Windows上安装SharedArray时遇到的编译错误,具体是因为缺少sys/mman.h头文件。我需要仔细分析这个问题并提供解决方案。 首先,sys/mman.h是Unix/Linux系统特有的头文件,Windows上没有这个文件。SharedArray包原本是为这些系统设计的,所以在Windows上编译时会报错。用户提到现在openPCDet已经基本不调用SharedArray的方法,所以可能可以绕过这个依赖,但用户还是想安装它。 根据用户提供的参考链接,有一个修改版的SharedArray for Windows,由imaginary-friend94维护。用户需要安装这个修改版本。但安装过程中需要做一些调整,比如修改setup.py中的名称,将winsharedarray改为SharedArray,以及修改扩展模块的名称和相关方法。 我需要分步骤指导用户如何操作。首先,克隆仓库,然后修改setup.py中的内容,确保名称正确。接着,可能需要修改C++文件中的方法名称,以保持兼容性。最后,安装修改后的包。 另外,用户可能需要安装Visual Studio Build Tools来支持编译,因为Windows下编译C++扩展需要这些工具。还要注意Python版本和架构是否匹配,比如32位和64位的问题。 需要提醒用户仔细检查所有修改的地方,确保名称一致,避免因为拼写错误导致安装失败。如果用户不熟悉C++修改,可能会遇到困难,所以步骤要尽量详细。 总结解决方案步骤:安装依赖工具,下载修改版仓库,修改配置文件,编译安装,验证安装。同时,提供备选方案,比如使用Linux子系统或贡献代码,但主推修改版SharedArray的安装方法。</think>在Windows上安装SharedArray时因缺少$sys/mman.h$导致的编译失败,可通过以下步骤解决: ### 解决方案步骤 1. **安装前置工具** - 安装[Visual Studio Build Tools](https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/),勾选"C++桌面开发工具" - 安装Python开发依赖:`pip install wheel setuptools` 2. **获取修改版SharedArray** ```bash git clone https://github.com/imaginary-friend94/Shared-Array-for-Windows cd Shared-Array-for-Windows ``` 3. **修改配置文件** - 编辑`setup.py`: 1. 将`name='winsharedarray'`改为`name='SharedArray'` 2. 修改扩展模块定义: ```python Extension('SharedArray', # 原为'winsharedarray' sources=['./src/winsharedarraymodule.cpp'], include_dirs=['./src'], libraries=['Kernel32'], define_macros=[('WIN32', None)]) ``` 4. **修改源码兼容性** - 编辑`src/winsharedarraymodule.cpp`: ```cpp // 修改所有方法前缀:win_shared_array_ -> shared_array_ static PyMethodDef SharedArrayMethods[] = { {"shared_array_create", ...}, // 原为win_shared_array_create {"shared_array_open", ...}, {NULL, NULL} }; ``` 5. **安装修改后的包** ```bash python setup.py install ``` 6. **验证安装** ```python import SharedArray # 应无报错 ``` ### 关键修改说明 - 通过替换$sys/mman.h$的POSIX内存映射API,改用Windows的`CreateFileMapping`/`MapViewOfFile`等系统调用[^1] - 保持Python层接口名称不变,仅修改底层实现 - 依赖Windows内核库$Kernel32.lib$替代Linux的$libc$ ### 注意事项 1. 确保Python架构(x86/x64)与系统一致 2. 若编译报`LNK2001`错误,检查是否遗漏`Kernel32`库链接 3. 使用Python 3.6+版本
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值