Care and Feeding of a Python Environment

Environments

List your environments:

1
conda env list

Select an environment (Linux, OS X):

1
source activate tensorflow

Select an environment (Windows):

1
activate tensorflow

Deactivate Environment (Linux, OS X)

1
source deactivate

Deactivate Environment (Windows, Linux, OS X)

1
deactivate

Create/Delete Environment

Create an environment:

1
conda create --name tensorflow python=3.6

Delete an environment:

1
conda remove --name tensorflow --all

Update/install

Update app packages:

1
conda update --all

Update one package:

1
pip install tensorflow --upgrade

Update Python to latest point version:

1
conda update python

Update Python to later version:

1
conda install python=3.6

Version of a package:

1
2
3
4
5
6
7
8
(tensorflow)Jeffreys-MacBook-Pro:present jeff$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> print(tensorflow.__version__)
0.8.0
>>>

You might want to add a new environment to Jupyter notebook. By default, Jupyter will use
what ever environment you have active when you launch Jupyter. However, if you would like
to allow your new environment to be used in Jupyter execute the following:

For Mac:

1
2
3
source activate tensorflow
pip install ipykernel
python -m ipykernel install --user --name=tensorflow

For Windows:

1
2
3
activate tensorflow
pip install ipykernel
python -m ipykernel install --user --name=tensorflow

Jupyter Notebooks

It can be really handy to use Jupyter notebook to manage your different Python environments. To do this you must install Jupyter in your root Python environment (and each additional environment):

1
conda install jupyter

You must also install nb_conda in your root:

1
conda install nb_conda

You can also add support for R in Jupyter:

1
conda install -c r r-essentials