pybullet安装时出现fatal error C1083: 无法打开包括文件: “string.h”: No such file or directory

发布时间:2023年12月28日

pybullet安装时出现fatal error C1083: 无法打开包括文件: “string.h”: No such file or directory

报错原文:

      -----
      CloneTreeCreator.cpp
      D:\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 directory
      error: 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 pybullet
  Running 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.4
  latest version: 23.11.0

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=23.11.0



## Package Plan ##

  environment location: D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1

  added / updated specs:
    - pybullet


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    bullet-cpp-3.21            |       hcc40339_3        20.6 MB  conda-forge
    ca-certificates-2023.11.17 |       h56e8100_0         151 KB  conda-forge
    certifi-2023.11.17         |     pyhd8ed1ab_0         155 KB  conda-forge
    pybullet-3.21              |   py38hcc40339_3        63.0 MB  conda-forge
    python_abi-3.8             |           2_cp38           4 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        83.8 MB

The following NEW packages will be INSTALLED:

  bullet-cpp         conda-forge/win-64::bullet-cpp-3.21-hcc40339_3
  pybullet           conda-forge/win-64::pybullet-3.21-py38hcc40339_3
  python_abi         conda-forge/win-64::python_abi-3.8-2_cp38

The 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_0
  certifi            anaconda/pkgs/main/win-64::certifi-20~ --> conda-forge/noarch::certifi-2023.11.17-pyhd8ed1ab_0


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

安装成功了

文章来源:https://blog.csdn.net/weixin_44584198/article/details/135279264
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。