【发布时间】:2021-12-18 20:18:35
【问题描述】:
将 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'
>>>
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 解释器设置如下:
【问题讨论】:
-
你们是如何启动 Zeppelin 的?
-
我导航到我的项目文件夹并执行 zstart 命令
-
从你运行
zstart的终端,请你启动一个Python shell并尝试import pandas as pd? -
我已经编辑了我的帖子。请参见上文。
-
您是否将
pandas库安装到Zeppelin 使用的环境中?看起来pandas没有安装。
标签: python pandas apache-zeppelin spark-notebook