简体   繁体   English

如何在conda创建的环境中启动jupyter?

[英]How to start jupyter in an environment created by conda?

I use conda created an environment called testEnv and activated it, after that I use the command jupyter notebook to call the jupyter editor. 我使用conda创建了一个名为testEnv的环境并将其激活,然后使用命令jupyter notebook调用jupyter编辑器。 It works, but the problem is that, I can only create file in the root environment. 它可以工作,但是问题是,我只能在根环境中创建文件。 How can I create file in testEnv environment? 如何在testEnv环境中创建文件?

Here are the steps what I have done: 这是我已完成的步骤:

$ conda create -n testEnv python=3.5 # create environmet
$ source activate testEnv # activate the environmet

(testEnv)$ jupyter notebook # start the jupyter notebook

Here are the result, which shows I can only create file with in "root" but not in "testEnv" (There is only Root , but no testEnv ): 结果是,这表明我只能在“ root”中创建文件,而不能在“ testEnv”中创建文件(只有Root ,而没有testEnv ):

在此处输入图片说明

In the Tab Conda , I can see the testEnv , but how can I switch to it? 在Tab Conda ,我可以看到testEnv ,但是如何切换到它呢?

在此处输入图片说明

You have two options. 您有两个选择。 You can install the Jupyter Notebook into each environment, and run the Notebook from that environment: 您可以将Jupyter Notebook安装到每个环境中,然后在该环境中运行Notebook:

conda create -n testEnv python=3.5 notebook
source activate testEnv
jupyter notebook

or you need to install the IPython kernel from testEnv into the environment from which you want to run Jupyter Notebook. 或者您需要从testEnv安装IPython内核到要运行Jupyter Notebook的环境中。 Instructions are here: http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments To summarize: 说明在这里: http : //ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments总结:

conda create -n testEnv python=3.5
source activate testEnv
python -m ipykernel install --user --name testEnv --display-name "Python (testEnv)"
source deactivate
jupyter notebook

The answer is that you probably shouldn't do this. 答案是您可能不应该这样做。 Python virtualenvs and Conda environments are intended to determine the resources available to the Python system, which are completely independent of your working directory. Python virtualenvs和Conda环境旨在确定Python系统可用的资源,这些资源完全独立于您的工作目录。

You can use the same environment to work on multiple projects, as long as they have the same dependencies. 您可以使用相同的环境来处理多个项目,只要它们具有相同的依赖关系即可。 The minute you start tweaking the environment you begin messing with something that is normally automatically maintained. 在您开始调整环境的那一刻,您就会开始使用通常会自动维护的东西弄乱。

So perhaps the real question you should ask yourself is "why do I think it's a good idea to store my notebooks inside the environment used to execute them." 因此,也许您应该问自己的真正问题是:“为什么我认为将我的笔记本存储在执行它们的环境中是个好主意”。

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

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