1

I need to intall d2l package with

pip install d2l==1.0.0b0

However, whenever I try to download it to google colab, the following error occurs:

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting d2l==1.0.0-beta0
  Using cached d2l-1.0.0b0-py3-none-any.whl (141 kB)
Collecting jupyter (from d2l==1.0.0-beta0)
  Using cached jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from d2l==1.0.0-beta0) (1.22.4)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from d2l==1.0.0-beta0) (3.7.1)
Requirement already satisfied: matplotlib-inline in /usr/local/lib/python3.10/dist-packages (from d2l==1.0.0-beta0) (0.1.6)
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from d2l==1.0.0-beta0) (2.27.1)
Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from d2l==1.0.0-beta0) (1.5.3)
Collecting gym==0.21.0 (from d2l==1.0.0-beta0)
  Using cached gym-0.21.0.tar.gz (1.5 MB)
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Preparing metadata (setup.py) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

How can I install d2l package on google colab?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
minjae35
  • 11
  • 1

2 Answers2

1

TL;DR Downgrade your setuptools==65.5.0 and wheel<0.40.0

!pip install setuptools==65.5.0 "wheel<0.40.0"

A bit more detail:

The issue is related to this post where the version of wheel and setuptools that Colab comes with by default is unable to install gym==0.21.0, which is a dependency of the version of d2l==1.0.0b0 cached in Colab.

The authors of d2l have updated 1.0.0b0 to remove this dependency, but the changes are not reflected in the current versions of Colab.

To summarize the linked post, the issue is with the latest version of wheel no longer being able to parse a dependency version string in the setup.py of gym==0.21.0. There is a workaround, which is to downgrade your versions of wheel and setuptools:

# I have read that 0.66.0 also works, but I haven't been able to
# verify this
!pip install setuptools==66.0.0 "wheel<0.40.0"

You should then be able to successfully run the following after restarting your kernel:

!pip install d2l==1.0.0b0
arturomp
  • 28,790
  • 10
  • 43
  • 72
knight
  • 300
  • 2
  • 7
0
!pip install setuptools==65.5.0 "wheel<0.40.0"
m_here
  • 41
  • 7
  • 1
    Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. **Would you kindly [edit] your answer to include additional details for the benefit of the community?** – Jeremy Caney Jun 24 '23 at 00:09
  • Thanks @m_here! It seems like you were trying to correct the answer above. It's best to do that as a comment or as a suggested edit! – arturomp Jun 26 '23 at 15:03