pybullet安装时出现fatal error C1083: 无法打开包括文件: “string.h”: No such file or directory
报错原文:
-----CloneTreeCreator.cppD:\Program_Professional\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\cstring(11): fatal error C1083: 无法打开包括文件: “string.h”: No such file or directoryerror: command 'D:\\Program_Professional\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\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 pybulletRunning setup.py clean for pybullet
Failed to build pybullet
ERROR: Could not build wheels for pybullet, which is required to install pyproject.toml-based projects
网上看了很多回答,都没有能够解决问题。
失败尝试1:Window10 SDK问题
我之前就装过VS了,环境都是满足要求的,也试过同时安装Window10 SDK和Window11 SDK,我的尝试没有什么作用。
失败尝试2:Window10 SDK的路径问题
之前pip安装老是报错io.h找不到,当时就在系统变量和用户变量中添加了路径,当时是解决了找不到io.h的问题的,但是在这个问题中不起作用。
此外,添加的路径对报错似乎没有作用,报错的路径还是D:\Program_Professional\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\cstring(11): fatal error C1083
实际上,string.h在\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38\include\ucrt里面也有,但是依旧报找不到文件。
失败尝试3:粘贴文件到目录
我把ucrt里面的所有头文件都复制到了\BuildTools\VC\Tools\MSVC\14.38.33130\include\里面,但是又报错找不到windows.h,于是放弃这种方法。
成功尝试3:使用conda安装
参考:https://anaconda.org/conda-forge/pybullet
conda install -c conda-forge pybullet
(tensorflow-gpu-v1) C:\Users\24762\Downloads\bullet3-master\bullet3-master>conda install -c conda-forge pybullet
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done==> WARNING: A newer version of conda exists. <==current version: 23.7.4latest version: 23.11.0Please update conda by running$ conda update -n base -c defaults condaOr to minimize the number of packages updated during conda update useconda install conda=23.11.0## Package Plan ##environment location: D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1added / updated specs:- pybulletThe following packages will be downloaded:package | build---------------------------|-----------------bullet-cpp-3.21 | hcc40339_3 20.6 MB conda-forgeca-certificates-2023.11.17 | h56e8100_0 151 KB conda-forgecertifi-2023.11.17 | pyhd8ed1ab_0 155 KB conda-forgepybullet-3.21 | py38hcc40339_3 63.0 MB conda-forgepython_abi-3.8 | 2_cp38 4 KB conda-forge------------------------------------------------------------Total: 83.8 MBThe following NEW packages will be INSTALLED:bullet-cpp conda-forge/win-64::bullet-cpp-3.21-hcc40339_3pybullet conda-forge/win-64::pybullet-3.21-py38hcc40339_3python_abi conda-forge/win-64::python_abi-3.8-2_cp38The following packages will be SUPERSEDED by a higher-priority channel:ca-certificates anaconda/pkgs/main::ca-certificates-2~ --> conda-forge::ca-certificates-2023.11.17-h56e8100_0certifi anaconda/pkgs/main/win-64::certifi-20~ --> conda-forge/noarch::certifi-2023.11.17-pyhd8ed1ab_0Proceed ([y]/n)? yDownloading and Extracting PackagesPreparing transaction: done
Verifying transaction: done
Executing transaction: done
安装成功了