【发布时间】:2020-09-11 03:54:46
【问题描述】:
我使用 Jupyter 已经有一段时间了,它运行良好。我通过 Homebrew 安装了 Jupyter 和 Python。我在 MacOS 上运行。
昨天,我运行了命令brew upgrade,现在我的 Jupyter 笔记本找不到任何已安装的 python 包。我将以 Numpy 为例。
当在 Jupyter 笔记本中时,我尝试这样做
import numpy
我收到消息:
ModuleNotFoundError: No module named 'numpy'
但是,如果我在终端窗口中启动 python,那么我可以毫无问题地导入 Numpy。
我首先通过重新发出安装命令检查包是否安装正确
brew install numpy
哪个输出:
Warning: numpy 1.18.4 is already installed and up-to-date
To reinstall 1.18.4, run `brew reinstall numpy`
我也跑了
pip install numpy
得到:
Requirement already satisfied: numpy in /usr/local/lib/python3.7/site-packages (1.18.4)
现在,这是我感到困惑的地方,因为我希望路径指向 /usr/local/Cellar/ 之类的东西,所以我检查了 Jupyter 笔记本内部的路径:
import sys
sys.path
哪个输出:
['/Users/kseuro/Dropbox/Dev/',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python38.zip',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/lib-dynload',
'/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
'',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages/IPython/extensions',
'/Users/kseuro/.ipython']
好的,所以 Homebrew 希望 Jupyter 使用 Python3.8?所以我尝试了brew switch python 3.8 并得到了:
Error: python does not have a version "3.8" in the Cellar.
python's installed versions: 3.7.7
我觉得我现在已经超出了我的能力范围,需要帮助来确定下一步该做什么。我不想从改变路径开始。
建议?非常感谢。
【问题讨论】:
标签: python macos jupyter-notebook package homebrew