from IPython.core.display import HTML
with open('creative_commons.txt', 'r') as f:
html = f.read()
name = '2014-06-23-virtual_env'
html = '''
<small>
<p> This post was written as an IPython notebook.
It is available for <a href='https://ocefpaf.github.com/python4oceanographers/downloads/notebooks/%s.ipynb'>download</a>
or as a static <a href='https://nbviewer.ipython.org/url/ocefpaf.github.com/python4oceanographers/downloads/notebooks/%s.ipynb'>html</a>.</p>
<p></p>
%s''' % (name, name, html)
%matplotlib inline
from matplotlib import style
style.use('ggplot')
In my last post about conda I forgot to
mentioned one important step! We must add my binstar channel to make
python-oceans
available via conda. Also, I do not think I emphasized the
importance of creating virtual environments and how to create new ones. After
answering questions about this over e-mail I decided summarize all the steps
here for future reference.
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
(Be sure to download the right conda for your system!)
chmod +x miniconda.sh
./miniconda.sh -b
Miniconda
binaries to our pathexport PATH=/$HOME/miniconda/bin:$PATH
(If this is going to become your main python you should add that line to your
.bashrc
. I do not use it as my main python distribution, so I use a shell
script to add it to my path, call my virtual environment, and call ipython.)
conda config --add channels https://conda.binstar.org/ocefpaf
(This was the missing step! You can add more channels like this one for example.)
conda create --yes -n virtual_env_name python=2.7
(You can change the virtual_env_name
and the python version according to
your needs.)
source activate virtual_env_name
conda install oceans
conda create --yes -n other_virtual_env_name python=3.4
I do not use conda
as my system python, so I do not add its path to my
bashrc
. I wrote a small script that calls,
export PATH=/$HOME/miniconda/bin:$PATH && source activate virtual_env_name && ipython
If you need to install modules to your environment remove the ipython
call in
the end. If you want to add packages to your main conda environment remove the
source activate
call.
If you want to switch between virtual environments just type source deactivate
to exit the current env and source activate other_virtual_env_name
to enter the new env.
HTML(html)
This post was written as an IPython notebook. It is available for download or as a static html.