jupyter notebook 调用anaconda的虚拟环境时包的版本不是对应版本

问题:在base环境中,pytorch的版本为1.4.0;在torch环境中,pytorch的版本为1.2.0。然而如果在jupyter notebook里面新建torch环境,输出torch.__version__的结果为1.4.0

确认版本号

在这里插入图片描述

确认环境存在

在这里插入图片描述

确认环境位置是否正确

在这里插入图片描述
在torch对应的路径后面加入/kernel.json,打开这个文件,看一下位置是否正确

vim  /root/.local/share/jupyter/kernels/torch/kernel.json

在这里插入图片描述
图中第三行的路径就是jupyter notebook中该虚拟环境依赖的解释器的路径,一开始路径写的是
/opt/conda/bin/python,也就是base环境下的解释器目录,在改为图中的新位置之后,jupyter notebook运行完美。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章