本文主要是介绍pip安装时出现fatal error C1083: 无法打开包括文件: “xxx.h”: No such file or directory-从根源解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
pip安装时出现fatal error C1083: 无法打开包括文件: “xxx.h”: No such file or directory-从根源解决
具体为:
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找不到,当时就在系统变量和用户变量中添加了路径path,但是在这个问题中不起作用。
此外,添加路径到path对报错似乎没有作用,报错的路径还是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,于是放弃这种修补方法。
成功尝试1:使用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
安装成功了
成功尝试2:手动配置环境变量-从根源解决
这种方法能够从根源解决fatal error C1083: 无法打开包括文件: “xxx.h”: No such file or directory的问题。当然需要首先安装好Window10 SDK,不然可能找不到下面的这些目录(推荐使用Visual Studio Installer安装,安装我之前截图的配置,当然我是window11系统因此用的是Window11 SDK)。
之前的环境变量都是在系统变量中的path中添加,实际上应该在INCLUDE(我电脑中没有自动生成,需要手动创建这个系统变量)中添加,如下所示:
此外,还需要在系统变量的LIB环境下添加(没有现成的也要手动创建,依据编译器的位数选择x86还是x64),有童鞋问为什么加那么多,因为有不同的报错,我自己尝试的时候就是报错一个就添加一个来着:
添加环境变量后一定要重启电脑,再次运行pip命令,如果出现LNK1158: 无法运行“rc.exe” 就参考下面文章解决:
【问题解决】LINK : fatal error LNK1158: 无法运行“rc.exe”
这篇关于pip安装时出现fatal error C1083: 无法打开包括文件: “xxx.h”: No such file or directory-从根源解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!