0

I've been trying to install the gym library via pip install gym I get the following error

WARNING: Discarding https://files.pythonhosted.org/packages/87/86/3f5467531428b6ce6f3c12d3121b4304d2ea1536a50775a4df036add37b8/gym-0.23.1.tar.gz#sha256=d0f9b9da34edbdace421c9442fc9205d03b8d15d0fb451053c766cde706d40e0 (from https://pypi.org/simple/gym/) (requires-python:>=3.7). Requested gym==0.23.1 from https://files.pythonhosted.org/packages/87/86/3f5467531428b6ce6f3c12d3121b4304d2ea1536a50775a4df036add37b8/gym-0.23.1.tar.gz#sha256=d0f9b9da34edbdace421c9442fc9205d03b8d15d0fb451053c766cde706d40e0 has inconsistent version: filename has '0.23.1', but metadata has '0.23.1'
ERROR: Could not find a version that satisfies the requirement gym==0.23.1
ERROR: No matching distribution found for gym==0.23.1

pip then defaults to trying to install previous versions 0.23.0, 0.22.0 and so on. I get the following warning for all versions and none installs.

request gym from <link> has inconsistent version: filename has '0.9.0', but metadata has '0.9.0'

After some Googling for similar errors, I tried updating pip python3 -m pip install --upgrade pip setuptools wheel but I get the same problem with version mismatch, and it tries to install old versions of pip and fails.

I'm on Python 3.10.4 and pip 21.0 under Arch Linux.

edit: The same problem happens to any package I try to install with pip.

Overflown
  • 11
  • 4
  • Sometimes the actual modules you're looking for aren't installed by there name for example –  May 05 '22 at 10:50
  • ```win32api``` is installed by ```pip install pywin32``` –  May 05 '22 at 10:51
  • https://stackoverflow.com/questions/67074684/pip-has-problems-with-metadata –  May 05 '22 at 10:57

3 Answers3

1

I found a solution here.

The problem seems to be caused by the python-pip package under Arch Linux.

One possible way to fix it:

sudo pacman -Rncs python-pip
python -m ensurepip
Overflown
  • 11
  • 4
0

If you cannot figure out pip use git

git clone https://github.com/openai/gym
cd gym
pip install -e .
0

Try to install with an upgrade option to install the latest without cache since looks that the latest version is stable:

pip install gym -U --no-cache-dir

-U, --upgrade Upgrade all packages to the newest available version

--no-cache-dir Disable the cache

If this won't help you can try to install using legacy version resolver (as per https://github.com/pypa/pip/issues/9203):

pip install gym -U --no-cache-dir --use-deprecated=legacy-resolver
yyunikov
  • 5,719
  • 2
  • 43
  • 78
  • Disabling the cache does not solve the issue. The second command returns an error: ` ERROR: Exception: File "/home/user/.local/lib/python3.10/site-packages/packaging/specifiers.py", line 728, in contains item = parse(item) File "/home/user/.local/lib/python3.10/site-packages/packaging/version.py", line 49, in parse return Version(version) File "/home/user/.local/lib/python3.10/site-packages/packaging/version.py", line 264, in __init__ match = self._regex.search(version) TypeError: expected string or bytes-like object ` – Overflown May 05 '22 at 11:43