【发布时间】:2020-03-05 20:32:00
【问题描述】:
我正在使用 Python 的 Jupyter Notebooks,并且一直在尝试从同一文件夹中的另一个文件导入名为 thresh_mean 的变量。
import scipy.io as sio
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from firstsound import thresh_mean #this line
但是,我得到了这个错误:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-42-1ee7c2613f81> in <module>
4 import pandas as pd
5 import matplotlib.pyplot as plt
----> 6 import firstsound
ModuleNotFoundError: No module named 'firstsound'
有谁知道为什么会发生这种情况以及如何导入该变量?
【问题讨论】:
-
firstsound安装在哪里?这个问题比尝试从模块中导入名称更广泛;无法创建模块本身。 -
我的桌面上有一个文件夹。在该文件夹中有一个名为 firstsound.ipynb 的 jupyter 笔记本,在同一个文件夹中是我正在编写的文件。我正在尝试将 firstsound.pynb 中的变量调用到当前笔记本中。
-
我自己不使用 Jupyter;它是否将
.pynb文件识别为有效模块? Python 本身没有。 -
Jupyter 笔记本的扩展名是
.ipynb,它们不能像 Python 那样导入。
标签: python variables jupyter-notebook python-import