【发布时间】:2021-05-23 07:13:36
【问题描述】:
请帮忙,我在运行 jupyter notebook 时遇到以下错误。
import numpy as np
import pandas as pd
from helper import boston_dataframe
np.set_printoptions(precision=3, suppress=True)
错误:
ImportError Traceback (most recent call last)
<ipython-input-3-a6117bd64450> in <module>
1 import numpy as np
2 import pandas as pd
----> 3 from helper import boston_dataframe
4
5
ImportError: cannot import name 'boston_dataframe' from 'helper' (/Users/irina/opt/anaconda3/lib/python3.8/site-packages/helper/__init__.py)
【问题讨论】:
-
我怀疑你安装了
helper,也就是这个代码:github.com/gmr/helper 可以从helper项目下的pypi 获得。它不包含boston_dataframe变量。所以这里的问题是你打算为这个笔记本使用哪个helper?这个笔记本是否有helper代码? -
笔记本附带了一个帮助文件。我已经下载了。它适用于其他笔记本,但不适用于这个
-
这似乎是一个相对路径。请参阅下面的答案。如果您想更普遍地使用它,那么您将希望以多种方式包含它,例如将目录添加到 PYTHONPATH。但是在同一个地方有这个特定的代码会很清楚你正在使用哪个
helperlibrary/module。
标签: python