简体   繁体   English

jupyter笔记本选择python

[英]jupyter notebook select python

I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. 我在Windows机器上安装了anaconda2和anaconda3,无法访问Internet和管理员权限。 How can I switch between python 2 and 3 when starting jupyter? 启动jupyter时如何在python 2和3之间切换? Basic "jupyter notebook" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation? 基本的“ jupyter笔记本”命令启动python2。通过Internet,我将为python 3添加环境,并在启动后在jupyter笔记本中选择它,但是在这种情况下我该怎么做?

There's important points to consider: 有几点要考虑:

  • you have to have jupyter notebook installed in each environment you want to run it from 您必须在jupyter notebook中运行它的每个环境中都安装了jupyter notebook
  • if jupyter is only installed in one environment, your notebook will default to that environment no matter from which environment your start it, and you will have no option to change the notebook kernel (ie the conda package, and therefore which python version to use for your notebook) 如果jupyter仅安装在一个环境中,则无论从哪个环境启动,笔记本电脑都将默认使用该环境,并且您将无权更改笔记本电脑的内核(即conda软件包,因此将使用哪个python版本)您的笔记本)

You can list the packages in your environment with conda list . 您可以使用conda list环境中的软件包。 You can also check what environments exist with conda info --envs to make sure there's indeed one with python 3 (and use conda list to check it has jupyter installed). 您还可以使用conda info --envs检查存在哪些环境,以确保确实存在python 3环境(并使用conda list检查是否已安装jupyter)。

From what you write, since your notebook defaults to python2, conda list should show you python 2 related packages. 从您编写的内容来看,由于笔记本默认为python2,因此conda list应显示与python 2相关的软件包。 So, as has been pointed, first activate the anaconda environment for python3 with the command activate your_python3_environment then restart your Notebook. 因此,正如已经指出的那样,首先使用命令activate your_python3_environment python3的anaconda环境,然后重新启动Notebook。 You don't need internet for this but you do need to be able to swap between anaconda2 and 3 (which you say are both installed) and both should have jupyter installed. 您不需要互联网,但是您确实需要能够在anaconda2和3(您都说已经安装)之间进行交换,并且都应该安装了jupyter。

Did you install python by Anaconda? 您安装了Anaconda的python吗?

Try to install under Anaconda2/envs when choosing destination folder, 选择目标文件夹时,尝试在Anaconda2 / envs下安装,

like this: D:/Anaconda2/envs/py3 像这样:D:/ Anaconda2 / envs / py3

then"activate py3" by cmd, py3 must be then same name of installation folder 然后通过cmd“激活py3”,则py3必须与安装文件夹名称相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM