12

I have installed Anaconda for my Machine Learning course. I'm using it as IPython (Jupyter) notebook, in which we have lessons. OS is Ubuntu 14.04 LTS. Basically, I always run it from Terminal with:

jupyter notebook

I have created new environment called su_env from root environment (exact copy) with one package added. Now, I'm wondering: how can I set environment su_env as default one? I have dozen of notebooks so it's annoying to set up each time for every notebook the environment, in "web" GUI of Jupyter.

EDIT: I'm interested in a solution where you don't have to set environment before running notebook. My logic is that, somehow, automagically, jupyter sets root environment on its own while starting up. Because of that, I'm wondering is it possible to set some config file or something so jupyter sets su_env instead of root. Also, if you know that's not possible (and why), I would like to know that.

ceruleus
  • 450
  • 1
  • 6
  • 18
  • Possible duplicate of [How to change default Anaconda python environment](https://stackoverflow.com/questions/28436769/how-to-change-default-anaconda-python-environment) – stenlytw Apr 17 '18 at 08:10

4 Answers4

8

First activate the conda environment from the command line, then launch the notebook server.

For example:

$ source activate env_name
$ jupyter notebook

jupyter notebook list of environments with env_name as the default environment

Note: This might only work with environments that were created from within Jupyter Notebook, not environments that were created using conda create on the command line.

jkdev
  • 11,360
  • 15
  • 54
  • 77
  • 2
    Thanks! I've seen that UI but I thought that I can set the default in that UI by putting checkmark under *Default?* or something like that. I'm wondering that there is no other option so you don't have to activate and deactivate environment for each session. So I will wait some more time to see if someone has the other answer. – ceruleus Aug 22 '16 at 08:56
  • What if I use `python3 -m venv env` and I don't see `conda` menu ? – Dmitriy Ogureckiy Aug 07 '22 at 16:28
3

In your ~/.bashrc, include the line:

alias jupyter="source activate su_env; jupyter"

This will condense the two commands into one, and you will activate su env whenever you call jupyter notebook or lab or whatever

Oliver Sherouse
  • 331
  • 1
  • 3
1

Edit your bashrc and add source activate su_env then that env will always be active. To switch back to to root (or any other env) source activate env_name

Doryx
  • 377
  • 4
  • 12
1

You can use this on conda prompt:

conda activate env_name

jupyter notebook

source activate env_name gives me an error: 'source' is not recognized as an internal or external command, operable program, or batch file.