ubuntu 22.04安装d2l
参考官方安装教程 https://zh.d2l.ai/chapter_installation/index.html
如果遇到启动 jupyter notebook 报错
AttributeError Traceback (most recent call last)
Cell In[1], line 3
1 import torch
2 from torch import nn
----> 3 from d2l import torch as d2l
File ~/miniconda3/envs/d2l/lib/python3.9/site-packages/d2l/torch.py:35
33 import requests
34 from IPython import display
---> 35 from matplotlib import pyplot as plt
36 from matplotlib_inline import backend_inline
38 d2l = sys.modules[__name__]
File ~/miniconda3/envs/d2l/lib/python3.9/site-packages/matplotlib/pyplot.py:2230
2228 dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
2229 # Set up the backend.
-> 2230 switch_backend(rcParams["backend"])
2232 # Just to be safe. Interactive mode can be turned on without
2233 # calling `plt.ion()` so register it again here.
2234 # This is safe because multiple calls to `install_repl_displayhook`
2235 # are no-ops and the registered function respect `mpl.is_interactive()`
2236 # to determine if they should trigger a draw.
2237 install_repl_displayhook()
...
--> 218 backend = matplotlib.rcParams._get("backend")
220 if ip and backend in ("inline", "module://matplotlib_inline.backend_inline"):
221 from IPython.core.pylabtools import activate_matplotlib
AttributeError: 'RcParams' object has no attribute '_get'
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
根因为 matplotlib 与 IPython/matplotlib_inline 版本不兼容。
更新matplotlib-inline版本
pip install "matplotlib-inline==0.1.6"

浙公网安备 33010602011771号