将 Pandas 库导入 Zeppelin 笔记本时,我遇到了一个奇怪的错误。这是我作为单元格的一部分的基本代码:
%python
import pandas as pd
df = pd.read_csv (r'target/youtube_videos.csv')
print (df)
我收到以下错误:
Fail to execute line 3: import pandas as pd
Traceback (most recent call last):
File "/tmp/1636039066525-0/zeppelin_python.py", line 153, in <module>
exec(code, _zcUserQueryNameSpace)
File "<stdin>", line 3, in <module>
ModuleNotFoundError: No module named 'pandas'
我试图看看我的 Python 路径是什么样的,它是:
%sh
python --version
python3-config --configdir
这给了我以下信息:
Python 3.7.0b3
/usr/lib/python3.8/config-3.8-x86_64-linux-gnu
我正在使用 Zeppelin 0.10.0。
编辑:
我尝试了以下方法:
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/ml-projects/ml-data-preparation-sandbox$ zstart
Please specify HADOOP_CONF_DIR if USE_HADOOP is true
Zeppelin start [ OK ]
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/ml-projects/ml-data-preparation-sandbox$ python
Python 3.7.0b3 (default, Mar 30 2018, 04:35:22)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>>
熊猫似乎已经安装:
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/ml-projects/ml-data-preparation-sandbox$ pip3 install pandas
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pandas in /usr/local/lib/python3.8/dist-packages (1.3.4)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/lib/python3/dist-packages (from pandas) (2.7.3)
Requirement already satisfied: numpy>=1.17.3 in /usr/lib/python3/dist-packages (from pandas) (1.17.4)
Requirement already satisfied: pytz>=2017.3 in /usr/lib/python3/dist-packages (from pandas) (2019.3)
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/ml-projects/ml-data-preparation-sandbox$
我什至在 Zeppelin 中设置了 python 解释器,如下所示: