I have tried to install gym using pip command and here is the error I get. I need help with it.
It also gives an error for pillow.'Running setup.py install for Pillow... error' I am very new at using pip for installation. Any help is greatly appreciated.
I already tried upgrading PIP and pillow but another error is found: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. gym 0.18.0 requires Pillow<=7.2.0, but you have pillow 8.1.0 which is incompatible.
(base) Meets-MacBook-Pro:~ meetpandya$ sudo pip install gym
WARNING: The directory '/Users/meetpandya/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting gym
Downloading gym-0.18.0.tar.gz (1.6 MB)
|████████████████████████████████| 1.6 MB 4.1 MB/s
Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from gym) (1.6.0)
Requirement already satisfied: numpy>=1.10.4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy-1.20.0rc2-py3.9-macosx-10.9-x86_64.egg (from gym) (1.20.0rc2)
Requirement already satisfied: pyglet<=1.5.0,>=1.4.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from gym) (1.5.0)
Collecting Pillow<=7.2.0
Downloading Pillow-7.2.0.tar.gz (39.1 MB)
|████████████████████████████████| 39.1 MB 54.5 MB/s
Collecting cloudpickle<1.7.0,>=1.2.0
Downloading cloudpickle-1.6.0-py3-none-any.whl (23 kB)
Requirement already satisfied: future in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pyglet<=1.5.0,>=1.4.0->gym) (0.18.2)
Using legacy 'setup.py install' for gym, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Pillow, since package 'wheel' is not installed.
Installing collected packages: Pillow, cloudpickle, gym
Running setup.py install for Pillow ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/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-8mkbg8ib/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/Pillow
cwd: /private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
Traceback (most recent call last):
File "/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/setup.py", line 864, in <module>
setup(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/install.py", line 546, in run
self.run_command('build')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/setup.py", line 694, in build_extensions
raise RequiredDependencyException(f)
__main__.RequiredDependencyException: zlib
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/setup.py", line 918, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-04_zwf00/pillow_6f6eee9de0ba4d39860be5d1c9e6fb13/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-8mkbg8ib/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/Pillow Check the logs for full command output.
Assuming that you have upgraded pip, please remove pillow and gym, and then install them again. If you find it hard, you can do easier with this command:
$ pip install --upgrade --force-reinstall Pillow, gym
or
$ pip install -I Pillow, gym
This conflict is because of the old gym version installed on your PC, so it should be force-reinstalled in order to be upgraded. If that doesn't solve the issue and the most recent version of gym needs an older version of Pillow (as I read in your question), then install the corresponding pillow version with this command:
$ pip install -I Pillow==7.2.0
I looked for the answer online and found a solution which works for me. Here it is,
zlib is the dependency to build pillow from source even if you have cached pillow in your site-packages. What I have done is,
brew install zlib
Add zlib libraries to the path, "brew info zlib" gives instructions for how to add zlib libraries as well as package-config file to the path. For Mac
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
pip install gym
This worked for me.
Python -> 3.9 Virtualenvironment -> Virtualenv (I haven't tested on conda)
I hope this works for you.
One other solution that worked for me, using conda, was:
pip uninstall pillow
pip install pillow
conda install -c conda-forge gym
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.