Install D2L beta library without errors

If you’re doing the Dive into Deep Learning (d2l) course or reading through the book yourself, you’ll have to eventually install the d2l library (specifically the beta version).

For example, when you run the install command:

!pip install d2l==1.0.0-beta0

You will most likely encounter an error similar to this:

  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.

I found the solution for this in a Github issue for the setuptools library. To fix the issue, you need to revert your version of setuptools, as well as the version of wheel to match:

!pip install wheel==0.38.4 setuptools==57.1.0

Then, restart your Colab/Jupyter runtime in order to pick up the change. Afterwards, if you run the following command again, it should succeed:

!pip install d2l==1.0.0-beta0