简体   繁体   English

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

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

I try to install Box2D on python but I get the error log:我尝试在 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\

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

How can I install Box2D and what means error code 1 by swig?我如何安装 Box2D 以及 swig 的错误代码 1 是什么意思?

I got the same error for Box2D, but solved as follows.我在 Box2D 上遇到了同样的错误,但解决方法如下。

I am using Anaconda environment with python3.6.我在 python3.6 中使用 Anaconda 环境。

try these.试试这些。

conda install swig conda 安装 swig

pip install box2d pip 安装 box2d

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

Extract the archive somewhere, add the path of the extracted directory to your PATH environment variable.将存档解压缩到某处,将解压缩目录的路径添加到 PATH 环境变量中。

Restart your cmd console window (close it and reopen it), do your pip install Box2D重新启动您的 cmd 控制台窗口(关闭它并重新打开它),执行pip install Box2D

I need to say that when on the anaconda environment, just add path, it also doesn't work.需要说的是,在anaconda环境下,只添加路径,也行不通。 we need to go on the Scripts with pip.exe.我们需要使用 pip.exe 继续执行脚本。 And run the command!并运行命令!

I got same error for Box2D.我对 Box2D 有同样的错误。
My Solution- downloading Microsoft Visual C++ Compiler for Python 2.7 from http://aka.ms/vcpython27 Complete the installation.我的解决方案——从http://aka.ms/vcpython27下载 Microsoft Visual C++ Compiler for Python 2.7 完成安装。
Then on anaconda prompt type command 'pip install Box2D'然后在 anaconda 提示符下键入命令“pip install Box2D”
Then type 'pip install gym[all]'然后输入“pip installgym[all]”
This will install the remaining dependencies.这将安装剩余的依赖项。

Hope this helps you.希望这对你有帮助。

Whoever is on Windows and facing this issue.谁在 Windows 上并面临这个问题。 Try installing C++ tools on windows through https://visualstudio.microsoft.com/visual-cpp-build-tools/ .尝试通过https://visualstudio.microsoft.com/visual-cpp-build-tools/在 windows 上安装 C++ 工具。 Then Install C++ tools through visual studio.然后通过visual studio安装C++工具。 This should solve your problem这应该可以解决您的问题

Try Install Box2D after this (make sure Swig is installed)在此之后尝试安装 Box2D(确保安装了 Swig)

Hello there I must be late but I hope this helps someone to solve his problem.你好,我一定迟到了,但我希望这有助于某人解决他的问题。

Just use any package manager like choco or conda or any other package manager to install the swig package to your machine then run the command to install box2d again.只需使用任何包管理器(如chococonda或任何其他包管理器将swig包安装到您的机器上,然后运行命令再次安装 box2d。

choco install swig巧克力安装swig

pip install box2d-py pip 安装 box2d-py

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

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