执行的代码:
bash
复制代码
import altair as alt
报错内容:
bash
复制代码
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import altair as alt
2 import pandas as pd
4 source = pd.DataFrame(
5 [
6 {"a": "a1", "b": "b1", "c": "x", "p": "0.14"},
(...)
33 ]
34 )
ModuleNotFoundError: No module named 'altair'
解决:
安装altair包
bash
复制代码
!pip install altair
等待安装完成:
bash
复制代码
Collecting altair
Downloading altair-5.3.0-py3-none-any.whl (857 kB)
------------------------------------- 857.8/857.8 kB 10.6 kB/s eta 0:00:00
Requirement already satisfied: jsonschema>=3.0 in d:\anaconda\anaconda\lib\site-packages (from altair) (4.17.3)
Requirement already satisfied: pandas>=0.25 in d:\anaconda\anaconda\lib\site-packages (from altair) (1.5.3)
Requirement already satisfied: typing-extensions>=4.0.1 in d:\anaconda\anaconda\lib\site-packages (from altair) (4.4.0)
Requirement already satisfied: toolz in d:\anaconda\anaconda\lib\site-packages (from altair) (0.12.0)
Requirement already satisfied: jinja2 in d:\anaconda\anaconda\lib\site-packages (from altair) (3.1.2)
Requirement already satisfied: numpy in d:\anaconda\anaconda\lib\site-packages (from altair) (1.23.5)
Requirement already satisfied: packaging in d:\anaconda\anaconda\lib\site-packages (from altair) (22.0)
Requirement already satisfied: attrs>=17.4.0 in d:\anaconda\anaconda\lib\site-packages (from jsonschema>=3.0->altair) (22.1.0)
Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in d:\anaconda\anaconda\lib\site-packages (from jsonschema>=3.0->altair) (0.18.0)
Requirement already satisfied: pytz>=2020.1 in d:\anaconda\anaconda\lib\site-packages (from pandas>=0.25->altair) (2022.7)
Requirement already satisfied: python-dateutil>=2.8.1 in d:\anaconda\anaconda\lib\site-packages (from pandas>=0.25->altair) (2.8.2)
Requirement already satisfied: MarkupSafe>=2.0 in d:\anaconda\anaconda\lib\site-packages (from jinja2->altair) (2.1.1)
Requirement already satisfied: six>=1.5 in d:\anaconda\anaconda\lib\site-packages (from python-dateutil>=2.8.1->pandas>=0.25->altair) (1.16.0)
Installing collected packages: altair
Successfully installed altair-5.3.0