xirururu
xirururu

Reputation: 5508

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. It works, but the problem is that, I can only create file in the root environment. How can I create file in testEnv environment?

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):

enter image description here

In the Tab Conda, I can see the testEnv, but how can I switch to it?

enter image description here

Upvotes: 5

Views: 6325

Answers (2)

darthbith
darthbith

Reputation: 19617

You have two options. You can install the Jupyter Notebook into each environment, and run the Notebook from that environment:

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. Instructions are here: http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments To summarize:

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

Upvotes: 7

holdenweb
holdenweb

Reputation: 37033

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.

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."

Upvotes: 1

Related Questions