Running a Conda Virtual Envroment

  • Before getting started check you have anaconda3 as your default version of python.

    $ which python

  • Create your virtual environment.

    The -n flag is used to set the name you choose for your environment.

    $ conda create -n mynewenv python=3

  • See a list of environments.

    You can check the list of available environments. This will now include the one you just created.

    $ conda env list

    This will show all of your personal environments as well as any general ones you have access to.
    One of these is pyuvdata which contains a stable version of the pyuvdata package used to convert raw SMA data to CASA MS.

  • Activate your conda environment.

    conda activate mynewenv

    You will see your command prompt change to show the name of the environment you are in.

  • Now you can install modules.

    If you check which pip you are running you will find it's a version dedicated to your new environment. E.g.

    (mynewenv)$ which pip

    You can now use pip to install whatever you need to your environment.

    (mynewenv)$ pip install astropy
    (mynewenv)$ pip install jupyter

    You can agree to all the install questions as it will all be contained in your venv.
    You wont be interfering with any system wide installations controlled by root.

  • Exit & activate as needed.

    When you are done you can deactivate the conda environment.

    $ conda deactivate

    The deactivate command returns you to your original session. Alternatively, you can just type exit which will exit you out of the whole shell, the same as using exit from your system environment.

    You can activate and deactivate the conda enviroments at will. Any changes you make or modules you install are rememebered.