I'm trying to install pygame.
My envrionment is
macOS 10.14.6 Mohave
Python 3.7.4 (downloaded from python.org)
I'm following the instructions on the Pygame site, namely using
pip install pygame
However this is failing with a fatal error, which can be summarised as fatal error:SDL.h filenot found The full install output is shown below.
Running setup.py install for pygame ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-mtm_fm2t/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-mtm_fm2t/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-vrvsxslr/install-record.txt --single-version-externally-managed --compile
cwd: /private/tmp/pip-install-mtm_fm2t/pygame/
Complete output (219 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/surfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/sysfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_camera_vidcapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
...whole bunch of copying removed for brevity...
copying examples/pixelarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/dropevent.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
running build_ext
building 'pygame.gfxdraw' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/src_c
creating build/temp.macosx-10.9-x86_64-3.8/src_c/SDL_gfx
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src_c/gfxdraw.c -o build/temp.macosx-10.9-x86_64-3.8/src_c/gfxdraw.o
In file included from src_c/gfxdraw.c:33:
In file included from src_c/pygame.h:32:
src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^~~~~~~
1 error generated.
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
error: command 'gcc' failed with exit status 1
ERROR: Command errored out with exit status 1:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys,
setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-
mtm_fm2t/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-
mtm_fm2t/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-vrvsxslr/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
The file SDL.h does exist when I search in finder, so i don't know why this install is failing.
I've tried the following to solve this but with no success.
installing with pip3 install pygame
installing with pip3 install pygame--2.0.0_dev4 option
And i've even tried downloading the SDL2 source and compiling.
They all fail (the SDL make fails chronically with errors around lzma.h
Has anyone got pygame running on macOS and Python 3.7.4 and can provide a list of detailed instructions and pre-requisites.
I just struggled with this same issue and was finally able to install pygame on a Mac with Mojave by using this command line:
pip3 install pygame --only-binary :all:
This will install a precompiled version of pygame and thus avoids the issue with missing header files (like SDL.h in your error message) which is occurring because pip is trying to compile pygame from source code that looks for these headers in /usr/include. With the latest updates to Mojave and Catalina, Apple no longer has a /usr/include directory. I did check the version of pygame installed with the --only-binary option and see it is a 2.0.0 dev version but so far it seems to work.
I was able to solve this issue by using easy_install pygame instead of pip. I suspect that it has something to do with python 3.8.
I struggled a lot in installing pygame on macOS Catalina. I tried creating the virtual env as well as many other options but Nothing worked for me. The default python is located in /usr/bin/python while the python3 that I installed is located in /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 so instead of using pip install pygame i triedeasy_install-3.8 pygame and it worked for me and when I opened the bin folder in /Library/Frameworks/Python.framework/Versions/3.8 location it has an easy_install-3.8 file. I do not know much about it but I think it has something to do with the python3.8
Related
I am trying to use tables in python3 on a new mac mini with the M1 chip.
I am getting multiple errors when running HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_1 pip3 install tables
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/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 /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-_1y0kbny
cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/
Complete output (293 lines):
* Using Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:10:52)
* USE_PKGCONFIG: False
* Found HDF5 headers at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/include``, library at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/lib``.
.. WARNING:: Could not find the HDF5 runtime.
The HDF5 shared library was *not* found in the default library
paths. In case of runtime problems, please remember to install it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_date5uv_p4uz.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
lzo_version_date();
^
1 error generated.
* Could not find LZO 2 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_datewh6xukqc.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
lzo_version_date();
^
1 error generated.
* Could not find LZO 1 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/BZ2_bzlibVersion0fv_km8c.c:2:5: error: implicit declaration of function 'BZ2_bzlibVersion' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
BZ2_bzlibVersion();
^
1 error generated.
* Could not find bzip2 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/blosc_list_compressorsqqaoy5ob.c:2:5: error: implicit declaration of function 'blosc_list_compressors' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
blosc_list_compressors();
^
1 error generated.
* Could not find blosc headers and library; using internal sources.
SSE2 detected and enabled
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extra_require'
warnings.warn(msg)
I installed blosc and tried to install python-lzo via pip install python-lzo but get
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/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 /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-c1_ztyik
cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/
Complete output (12 lines):
running bdist_wheel
running build
running build_ext
building 'lzo' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.9
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/include/lzo -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c lzomodule.c -o build/temp.macosx-10.9-x86_64-3.9/lzomodule.o
lzomodule.c:35:10: fatal error: 'lzo/lzo1x.h' file not found
#include <lzo/lzo1x.h>
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for python-lzo
Bonus points if you can help me understand why tables was never an issue on python2 (admittedly on a Windows machine, but I am getting all similar errors there too on python3)
These steps works for me.
Install Homebrew for Mac M1 (arm64 version)
Then install packages
brew install hdf5 c-blosc lzo bzip2
Check installation path
brew info -q hdf5 c-blosc lzo bzip2|grep '/opt/homebrew'
/opt/homebrew/Cellar/hdf5/1.12.0_3 (268 files, 19.4MB) *
/opt/homebrew/Cellar/c-blosc/1.21.0 (10 files, 1.5MB) *
/opt/homebrew/Cellar/lzo/2.10 (31 files, 580.4KB) *
/opt/homebrew/Cellar/bzip2/1.0.8 (26 files, 531.5KB)
...
Download and unarchive PyTables(PyTables-3.6.1 for me)
Compile
cd PyTables-3.6.1
python setup.py build --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3 --use-pkgconfig=FALSE --blosc=/opt/homebrew/Cellar/c-blosc/1.21.0 --lzo=/opt/homebrew/Cellar/lzo/2.10 --bzip2=/opt/homebrew/Cellar/bzip2/1.0.8
Install
python setup.py install --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3
UPDATE(2021-11-15): conda works now
conda install pytables
The tables module can be easily installed using Miniforge (which can be easily installed using pyenv or following their installation instructions):
https://github.com/conda-forge/miniforge
Once Miniforge is installed you can install tables on your M1 Mac using:
conda install pytables
You may try this link
https://github.com/PyTables/PyTables/issues/219#issuecomment-24117053
After many searches, I was able to install tables by setting the HDF5_DIR and
pip install git+https://github.com/PyTables/PyTables.git#master#egg=tables
I'm trying to do the follow code with OpenAI:
import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample())
but it throws the error:
fn = getattr(mod, attr_name)
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
And then I try to install box2d by pip install box2d-py throwing this error:
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Junior\Anaconda\envs\gym\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Junior\\AppData\\Local\\Temp\\pip-install-w8awn22p\\box2d-py\\setup.py'"'"'; __file__='"'"'C:\\Users\\Junior\\AppData\\Local\\Temp\\pip-install-w8awn22p\\box2d-py\\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\Junior\AppData\Local\Temp\pip-record-netg1nlq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Junior\Anaconda\envs\gym\Include\box2d-py'
cwd: C:\Users\Junior\AppData\Local\Temp\pip-install-w8awn22p\box2d-py\
Complete output (16 lines):
Using setuptools (version 45.2.0.post20200210).
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\Box2D
copying library\Box2D\Box2D.py -> build\lib.win-amd64-3.7\Box2D
copying library\Box2D\__init__.py -> build\lib.win-amd64-3.7\Box2D
creating build\lib.win-amd64-3.7\Box2D\b2
copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-3.7\Box2D\b2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D\Box2D.i to Box2D\Box2D_wrap.cpp
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
error: command 'swig.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Junior\Anaconda\envs\gym\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Junior\\AppData\\Local\\Temp\\pip-install-w8awn22p\\box2d-py\\setup.py'"'"'; __file__='"'"'C:\\Users\\Junior\\AppData\\Local\\Temp\\pip-install-w8awn22p\\box2d-py\\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\Junior\AppData\Local\Temp\pip-record-netg1nlq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Junior\Anaconda\envs\gym\Include\box2d-py' Check the logs for full command output.
what I have to do to install it successfully?
Windows support is at present moment experimental (source). That being said, on most of the occasions you will get it to work, but some of the functionality could be broken. Proceed with caution.
Here's what could work:
Install Anaconda.
Start Anaconda command line (it adds conda to the PATH).
conda create -c conda-forge -n gymenv swig pip - create base environment.
conda activate gymenv - activate it.
pip install Box2D gym - install base gym with Box2D.
(Optional) pip install gym[all] - install all components of Gym. You might run into errors.
If you get build errors on missing compilers, install Visual Studio Built Tools.
Depending on the component you're using, you might need e.g. pystan. Activate then the conda environment and install it, i.e. conda install pystan.
An alternative could be to try to install Gym directly through conda:
conda create -c conda-forge -c powerai -n gymenv gym swig pip pystan
This will install gym from powerai channel. Might work, but mind that it's not the latest nor seems to be supported by devs.
I got it sorted with just installing swig before gym[box2d] no anaconda needed
pip3 install swig
In my case, I used the conda to install Gym's Box2D:
conda install swig
conda install -c conda-forge gym-box2d
and got rid of this error.
(As a windows user) For me, the solution was to download and install the latest stable version of Build Tools pour Visual Studio (2022 currently). Then the pip install gym[box2d] worked.
I'm trying to install chatterbot on macOS with
python3 -m pip install chatterbot
and every time I get the same error during the step "Installing build dependencies ... /"
ERROR: Failed building wheel for spacy
Running setup.py clean for spacy
Failed to build spacy
ERROR: Could not build wheels for spacy which use PEP 517 and cannot be installed directly
Can someone please help?
Installing collected packages: spacy, chatterbot
Running setup.py install for spacy ... error
ERROR: Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-record-z9jsui8q/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/spacy
copying spacy/lemmatizer.py -> build/lib.macosx-10.9-x86_64-3.7/spacy
running build_ext
building 'spacy._align' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/spacy
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c spacy/_align.cpp -o build/temp.macosx-10.9-x86_64-3.7/spacy/_align.o -O2 -Wno-strict-prototypes -Wno-unused-function -stdlib=libc++
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-record-z9jsui8q/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/
You could try python3 -m pip install --no-binary spacy chatterbot, which should tell pip to not build the wheel
Alternately python3 -m pip install --no-use-pep517 chatterbot.
I had the same problem while installing kivy through command prompt.
If you use Pycharm then there is an easy way to avoid these problems.
Open Pycharm-->GoTo Files-->Settings-->Project-->Python Interpreter--> + sign-->then search for what you want to install. Check the version which works for you and install it.
If you get an error then try and install other versions of it. That would solve the issue.
Try installing the python-dev version.
For python3.7
sudo apt-get install python3.7-dev
For python3.6
sudo apt-get install python3.6-dev
In one of the scenarios where if you are using Anaconda, then you have to install using this command:
conda install -c conda-forge spacy, hope this helps !!
I had this issue with MacOS for a different package. I found this warning in the log:
WARNING: Building wheel for bottleneck failed: [Errno 13] Permission denied: '/Users/avi/Library/Caches/pip/wheels/87'
Then I gave my user access to the pip/wheels directory and then the installation worked.
Easy, try to run this:
pip install pep517
And then try to install again
python3 -m pip install chatterbot
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:\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.
How can I install Box2D and what means error code 1 by swig ?
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
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.
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 got the following error while trying to install pyaudio using pip3 in ubuntu 16.04:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
This should help
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Tested on Ubuntu 18.04, Python 3.7.2, pyaudio 0.2.11
Added 8th of Jan 2021:
On Ubuntu 20.04 you have to use:
$ sudo apt install portaudio19-dev python3-pyaudio
For Windows, here's what I've been going through...
There're several ways to install PortAudio
vcpkg, https://vcpkg.info/port/portaudio
winget, https://winget.run/pkg/intxcc/pyaudio
Or, manually build from source and install manually
download source, http://files.portaudio.com/download.html
build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs
Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually
pip install pyaudio --no-clean
find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
pip install from that directorye.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
Or,3rd party wheels
this answer said:
pip install pipwinpipwin install pyaudio
For MacOS (Intel/Apple Silicon):
Step 1:
brew install portaudio
Step 2:
brew --prefix portaudio
The output provided from the above command, will be required in Step 3, which will look something similar to /opt/homebrew/opt/portaudio
Step 3:
Create .pydistutils.cfg in your home directory
sudo nano ~/.pydistutils.cfg
then paste the following in the file, save and exit
[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Step 4:
pip3 install pyaudio
For Centos7/RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user