命令行python和jupyter笔记本使用两种不同版本的手电筒 [英] Command line python and jupyter notebooks use two different versions of torch

查看:207
本文介绍了命令行python和jupyter笔记本使用两种不同版本的手电筒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的conda环境中,从命令行Python和jupyter笔记本中导入火炬会产生两个不同的结果.

On my conda environment importing torch from command line Python and from a jupyter notebook yields two different results.

命令行Python:

$ source activate GNN
(GNN) $ python
>>> import torch
>>> print(torch.__file__)
/home/riccardo/.local/lib/python3.7/site-packages/torch/__init__.py
>>> print(torch.__version__)
0.4.1

Jupyter:

(GNN) $ jupyter notebook --no-browser --port=8890

import torch

print(torch.__file__)
/home/riccardo/.local/lib/python3.6/site-packages/torch/__init__.py

print(torch.__version__)
1.2.0+cu92

我尝试了在Jupyter中未显示的Conda环境中建议的步骤笔记本

$ conda install ipykernel
$ source activate GNN
(GNN) $ python -m ipykernel install --user --name GNN --display-name "Python (GNN)"
Installed kernelspec GNN in /home/riccardo/.local/share/jupyter/kernels/gnn

但这并不能解决问题.

推荐答案

您需要使用

conda activate myenv
conda install -n myenv ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

用您的环境名称替换myenv.稍后,在Jupyter Notebook中的选择内核"选项中,您将看到此Python (myenv)选项.

Replace myenv with the name of your environment. Later on, in your Jupyter Notebook, in the Select Kernel option, you will see this Python (myenv) option.

这篇关于命令行python和jupyter笔记本使用两种不同版本的手电筒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆