英文:
d2l package installation on google colab
问题
You can install the d2l package on Google Colab by running the following command:
!pip install d2l==1.0.0b0
This will install the d2l package with the specified version in your Google Colab environment.
英文:
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?
答案1
得分: 1
**TL;DR**
降级你的 `setuptools==65.5.0` 和 `wheel<0.40.0`
```python
!pip install setuptools==65.5.0 "wheel<0.40.0"
稍微详细一点:
这个问题与 这篇帖子 有关,其中 Colab 默认提供的 wheel
和 setuptools
版本无法安装 gym==0.21.0
,而这是 Colab 缓存中的 d2l==1.0.0b0
版本的一个依赖项。
d2l
的作者已经更新了 1.0.0b0 版本以删除此依赖项,但这些更改在当前版本的 Colab 中未得到反映。
总结一下 链接的帖子,问题出在最新版本的 wheel
无法解析 gym==0.21.0
的 setup.py 中的依赖版本字符串。有一个解决方法,就是降级你的 wheel
和 setuptools
版本:
# 我已经看到 0.66.0 也可以工作,但我还没有能够验证这一点
!pip install setuptools==66.0.0 "wheel<0.40.0"
然后重新启动内核后,你应该能够成功运行以下命令:
!pip install d2l==1.0.0b0
<details>
<summary>英文:</summary>
**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](https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ/76286033#76286033) 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](https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ/76286033#76286033), 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
</details>
# 答案2
**得分**: 0
!pip install setuptools==65.5.0 "wheel<0.40.0"
<details>
<summary>英文:</summary>
!pip install setuptools==65.5.0 "wheel<0.40.0"
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论