【问题标题】:How can I know that which python my jupyter notebook is using and how can I change to use conda python?我如何知道我的 jupyter notebook 使用的是哪个 python,如何更改为使用 conda python?
【发布时间】:2020-03-25 19:03:22
【问题描述】:

我试图在 Jupyter 笔记本中使用 Torch,但无法No module named 'torch' 我找到了这个 This is most certainly because your notebook is not using the same python as anaconda,并在 Jupyter 中检查了我的 python_version 并得到:3.7.6 但我不确定如何检查 anaconda 正在使用的 python 版本。

我该如何检查?然后我如何确保他们都使用相同的版本?

【问题讨论】:

  • 如何启动笔记本?

标签: python jupyter-notebook anaconda conda


【解决方案1】:

您可以找到 Jupyter 启动脚本并检查它使用的解释器:

user@pc:~$ which jupyter
/home/user/.local/bin/jupyter
user@pc:~$ cat /home/user/.local/bin/jupyter
#!/usr/bin/python3
# -*- coding: utf-8 -*-

在我的例子中是 /usr/bin/python3,所以它使用 Python 3。

您可以通过执行卸载当前版本并安装 Jupyter 以进行另一个 python 安装

pip3 uninstall jupyter
/path/to/another/python -m pip install jupyter

【讨论】:

  • 我无法运行第二个命令 'cat' 只有在 python3 where python3 /Users/user/miniconda3/bin/python3 /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /usr/local/bin/python3 /usr/bin/python3 而且我也不知道还有什么其他的使用路径...
猜你喜欢
  • 2017-04-03
  • 2021-09-22
  • 1970-01-01
  • 2011-05-15
  • 1970-01-01
  • 1970-01-01
  • 2019-06-29
  • 2017-10-09
相关资源
最近更新 更多