繁体   English   中英

Python 无法安装 Box2D swig.exe 失败,错误代码为 1

[英]Python can't install Box2D swig.exe failed with error code 1

我尝试在 python 上安装 Box2D,但我收到错误日志:

C:\>pip3 install Box2D
Collecting Box2D
  Using cached https://files.pythonhosted.org/packages/cc/7b/ddb96fea1fa5b24f8929714ef483f64c33e9649e7aae066e5f5023ea426a/Box2D-2.3.2.tar.gz
Building wheels for collected packages: Box2D
  Running setup.py bdist_wheel for Box2D ... error
  Complete output from command c:\users\hp-laptop\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP-LAP~1\\AppData\\Local\\Temp\\pip-install-r48_7g5v\\Box2D\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\HP-LAP~1\AppData\Local\Temp\pip-wheel-d2ghuwrx --python-tag cp36:
  Using setuptools (version 40.5.0).
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\Box2D
  copying library\Box2D\Box2D.py -> build\lib.win-amd64-3.6\Box2D
  copying library\Box2D\__init__.py -> build\lib.win-amd64-3.6\Box2D
  creating build\lib.win-amd64-3.6\Box2D\b2
  copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-3.6\Box2D\b2
  running build_ext
  building 'Box2D._Box2D' extension
  swigging Box2D\Box2D.i to Box2D\Box2D_wrap.cpp
  C:\Users\HP-Laptop\AppData\Local\Programs\Python\Python36\swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library\Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D\Box2D_wrap.cpp Box2D\Box2D.i
  C:\Users\HP-Laptop\AppData\Local\Programs\Python\Python36\Lib\pyprimtypes.swg(7) : Error: Syntax error in input(1).
  error: command 'C:\\Users\\HP-Laptop\\AppData\\Local\\Programs\\Python\\Python36\\swig.exe' failed with exit status 1

  ----------------------------------------
  Failed building wheel for Box2D
  Running setup.py clean for Box2D
Failed to build Box2D
Installing collected packages: Box2D
  Running setup.py install for Box2D ... error
    Complete output from command c:\users\hp-laptop\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP-LAP~1\\AppData\\Local\\Temp\\pip-install-r48_7g5v\\Box2D\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\HP-LAP~1\AppData\Local\Temp\pip-record-nv5dm4ru\install-record.txt --single-version-externally-managed --compile:
    Using setuptools (version 40.5.0).
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\Box2D
    copying library\Box2D\Box2D.py -> build\lib.win-amd64-3.6\Box2D
    copying library\Box2D\__init__.py -> build\lib.win-amd64-3.6\Box2D
    creating build\lib.win-amd64-3.6\Box2D\b2
    copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-3.6\Box2D\b2
    running build_ext
    building 'Box2D._Box2D' extension
    swigging Box2D\Box2D.i to Box2D\Box2D_wrap.cpp
    C:\Users\HP-Laptop\AppData\Local\Programs\Python\Python36\swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library\Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D\Box2D_wrap.cpp Box2D\Box2D.i
    C:\Users\HP-Laptop\AppData\Local\Programs\Python\Python36\Lib\pyprimtypes.swg(7) : Error: Syntax error in input(1).
    error: command 'C:\\Users\\HP-Laptop\\AppData\\Local\\Programs\\Python\\Python36\\swig.exe' failed with exit status 1

    ----------------------------------------
Command "c:\users\hp-laptop\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP-LAP~1\\AppData\\Local\\Temp\\pip-install-r48_7g5v\\Box2D\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\HP-LAP~1\AppData\Local\Temp\pip-record-nv5dm4ru\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\HP-LAP~1\AppData\Local\Temp\pip-install-r48_7g5v\Box2D\

我从Installing pocketsphinx python module: command 'swig.exe' failed without result 尝试了 windows 的所有解决方案。

我如何安装 Box2D 以及 swig 的错误代码 1 是什么意思?

我在 Box2D 上遇到了同样的错误,但解决方法如下。

我在 python3.6 中使用 Anaconda 环境。

试试这些。

conda 安装 swig

pip 安装 box2d

在这里下载 swig: http ://www.swig.org/download.html

将存档解压缩到某处,将解压缩目录的路径添加到 PATH 环境变量中。

重新启动您的 cmd 控制台窗口(关闭它并重新打开它),执行pip install Box2D

需要说的是,在anaconda环境下,只添加路径,也行不通。 我们需要使用 pip.exe 继续执行脚本。 并运行命令!

我对 Box2D 有同样的错误。
我的解决方案——从http://aka.ms/vcpython27下载 Microsoft Visual C++ Compiler for Python 2.7 完成安装。
然后在 anaconda 提示符下键入命令“pip install Box2D”
然后输入“pip installgym[all]”
这将安装剩余的依赖项。

希望这对你有帮助。

谁在 Windows 上并面临这个问题。 尝试通过https://visualstudio.microsoft.com/visual-cpp-build-tools/在 windows 上安装 C++ 工具。 然后通过visual studio安装C++工具。 这应该可以解决您的问题

在此之后尝试安装 Box2D(确保安装了 Swig)

你好,我一定迟到了,但我希望这有助于某人解决他的问题。

只需使用任何包管理器(如chococonda或任何其他包管理器将swig包安装到您的机器上,然后运行命令再次安装 box2d。

巧克力安装swig

pip 安装 box2d-py

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM