Python can't install Box2D swig.exe failed with error code 1
Question:
I try to install Box2D on python but I get the error log:
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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:UsersHP-LAP~1AppDataLocalTemppip-wheel-d2ghuwrx --python-tag cp36:
Using setuptools (version 40.5.0).
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win-amd64-3.6
creating buildlib.win-amd64-3.6Box2D
copying libraryBox2DBox2D.py -> buildlib.win-amd64-3.6Box2D
copying libraryBox2D__init__.py -> buildlib.win-amd64-3.6Box2D
creating buildlib.win-amd64-3.6Box2Db2
copying libraryBox2Db2__init__.py -> buildlib.win-amd64-3.6Box2Db2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2DBox2D.i to Box2DBox2D_wrap.cpp
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir libraryBox2D -keyword -w511 -D_SWIG_KWARGS -o Box2DBox2D_wrap.cpp Box2DBox2D.i
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36Libpyprimtypes.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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersHP-LAP~1AppDataLocalTemppip-record-nv5dm4ruinstall-record.txt --single-version-externally-managed --compile:
Using setuptools (version 40.5.0).
running install
running build
running build_py
creating build
creating buildlib.win-amd64-3.6
creating buildlib.win-amd64-3.6Box2D
copying libraryBox2DBox2D.py -> buildlib.win-amd64-3.6Box2D
copying libraryBox2D__init__.py -> buildlib.win-amd64-3.6Box2D
creating buildlib.win-amd64-3.6Box2Db2
copying libraryBox2Db2__init__.py -> buildlib.win-amd64-3.6Box2Db2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2DBox2D.i to Box2DBox2D_wrap.cpp
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir libraryBox2D -keyword -w511 -D_SWIG_KWARGS -o Box2DBox2D_wrap.cpp Box2DBox2D.i
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36Libpyprimtypes.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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersHP-LAP~1AppDataLocalTemppip-record-nv5dm4ruinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersHP-LAP~1AppDataLocalTemppip-install-r48_7g5vBox2D
I tried all solutions for windows from Installing pocketsphinx python module: command 'swig.exe' failed without result.
How can I install Box2D and what means error code 1 by swig ?
Answers:
download swig here : http://www.swig.org/download.html
Extract the archive somewhere, add the path of the extracted directory to your PATH environment variable.
Restart your cmd console window (close it and reopen it), do your pip install Box2D
I need to say that when on the anaconda environment, just add path, it also doesn’t work. we need to go on the Scripts with pip.exe. And run the command!
I got same error for Box2D.
My Solution-
downloading Microsoft Visual C++ Compiler for Python 2.7 from http://aka.ms/vcpython27
Complete the installation.
Then on anaconda prompt
type command ‘pip install Box2D’
Then type ‘pip install gym[all]’
This will install the remaining dependencies.
Hope this helps you.
I got the same error for Box2D, but solved as follows.
I am using Anaconda environment with python3.6.
try these.
conda install swig
pip install box2d
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.
choco install swig
pip install box2d-py
Whoever is on Windows and facing this issue. Try installing C++ tools on windows through https://visualstudio.microsoft.com/visual-cpp-build-tools/.
Then Install C++ tools through visual studio. This should solve your problem
Try Install Box2D after this (make sure Swig is installed)
I try to install Box2D on python but I get the error log:
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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:UsersHP-LAP~1AppDataLocalTemppip-wheel-d2ghuwrx --python-tag cp36:
Using setuptools (version 40.5.0).
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win-amd64-3.6
creating buildlib.win-amd64-3.6Box2D
copying libraryBox2DBox2D.py -> buildlib.win-amd64-3.6Box2D
copying libraryBox2D__init__.py -> buildlib.win-amd64-3.6Box2D
creating buildlib.win-amd64-3.6Box2Db2
copying libraryBox2Db2__init__.py -> buildlib.win-amd64-3.6Box2Db2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2DBox2D.i to Box2DBox2D_wrap.cpp
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir libraryBox2D -keyword -w511 -D_SWIG_KWARGS -o Box2DBox2D_wrap.cpp Box2DBox2D.i
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36Libpyprimtypes.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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersHP-LAP~1AppDataLocalTemppip-record-nv5dm4ruinstall-record.txt --single-version-externally-managed --compile:
Using setuptools (version 40.5.0).
running install
running build
running build_py
creating build
creating buildlib.win-amd64-3.6
creating buildlib.win-amd64-3.6Box2D
copying libraryBox2DBox2D.py -> buildlib.win-amd64-3.6Box2D
copying libraryBox2D__init__.py -> buildlib.win-amd64-3.6Box2D
creating buildlib.win-amd64-3.6Box2Db2
copying libraryBox2Db2__init__.py -> buildlib.win-amd64-3.6Box2Db2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2DBox2D.i to Box2DBox2D_wrap.cpp
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir libraryBox2D -keyword -w511 -D_SWIG_KWARGS -o Box2DBox2D_wrap.cpp Box2DBox2D.i
C:UsersHP-LaptopAppDataLocalProgramsPythonPython36Libpyprimtypes.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:usershp-laptopappdatalocalprogramspythonpython36python.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('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersHP-LAP~1AppDataLocalTemppip-record-nv5dm4ruinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersHP-LAP~1AppDataLocalTemppip-install-r48_7g5vBox2D
I tried all solutions for windows from Installing pocketsphinx python module: command 'swig.exe' failed without result.
How can I install Box2D and what means error code 1 by swig ?
download swig here : http://www.swig.org/download.html
Extract the archive somewhere, add the path of the extracted directory to your PATH environment variable.
Restart your cmd console window (close it and reopen it), do your pip install Box2D
I need to say that when on the anaconda environment, just add path, it also doesn’t work. we need to go on the Scripts with pip.exe. And run the command!
I got same error for Box2D.
My Solution-
downloading Microsoft Visual C++ Compiler for Python 2.7 from http://aka.ms/vcpython27
Complete the installation.
Then on anaconda prompt
type command ‘pip install Box2D’
Then type ‘pip install gym[all]’
This will install the remaining dependencies.
Hope this helps you.
I got the same error for Box2D, but solved as follows.
I am using Anaconda environment with python3.6.
try these.
conda install swig
pip install box2d
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.
choco install swig
pip install box2d-py
Whoever is on Windows and facing this issue. Try installing C++ tools on windows through https://visualstudio.microsoft.com/visual-cpp-build-tools/.
Then Install C++ tools through visual studio. This should solve your problem
Try Install Box2D after this (make sure Swig is installed)