【问题标题】:Change python2 to python3 when using the terminal for jupyter notebook使用 jupyter notebook 的终端时将 python2 更改为 python3
【发布时间】:2020-12-25 10:25:48
【问题描述】:

我希望有人可以帮助我解决以下问题;

在我的 Mac 上,我默认安装的是 Python 2.x。我现在必须从终端用 Python 3.8 打开 Jupyter notebook。我已经下载了 Python 3.8。我试过python3 -m notebook,但这似乎不起作用。有人知道怎么做吗?

要下载我在终端中使用的 pip:

$ sudo easy_install pip

使用终端安装包

$ pip install rdflib

然后我在我的终端中安装了 Jupyter notebook 使用:

$ pip install jupyterlab

谢谢!

【问题讨论】:

  • 嗨 YYY,欢迎来到 Stack Overflow。你安装了 Jupyter 吗?如果是这样,你是怎么做到的?
  • 运行python3 -m notebook后终端的输出是什么?
  • @David Z 我在终端中使用了:$ pip install jupyterlab,在此之前我已经安装了 pip。
  • 每个 Python 都使用自己的模块 - 您必须使用 pip3 install ...python3 -m pip install ... 安装它
  • @YYY 谢谢,你能把这些信息编辑成你的问题吗?

标签: python python-3.x macos terminal jupyter-notebook


【解决方案1】:

由于 Python 2 是您系统上的默认设置,pip 很可能(但不确定)运行 Python 2 版本的 Pip。您可以通过运行检查

$ pip --version

它将打印出 pip 使用的 Python 版本。如果你发现它是 Python 2,那就意味着运行 pip install 来安装一个包只会为 Python 2 安装它。

为了使包在您的默认 Python 3 版本中可用,您必须运行

pip3 install notebook

我猜对你来说,Python 3 的默认版本可能是 Python 3.8,除非你还 另一个 安装了 Python 3 版本。如果你这样做了,那么你可能需要运行

pip3.8 install notebook

完全确定它是随 Python 3.8 而不是您安装的任何其他版本一起安装的。

【讨论】:

    猜你喜欢
    • 2017-07-12
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 1970-01-01
    • 1970-01-01
    • 2023-02-06
    相关资源
    最近更新 更多