Switching between Python 2 and Python 3 environmentsΒΆ

You can easily maintain separate environments for Python 2 programs and Python 3 programs on the same computer, without worrying about the programs interacting with each other. Switching to an environment is called activating it.


  1. Create a Python 2 environment named py2, install Python 2.7:

    conda create --name py2 python=2.7
    
  2. Create a new environment named py3, install Python 3.5:

    conda create --name py3 python=3.5
    

    Now you have two environments with which to work. You can install packages and run programs as desired in either one.

  3. Activate and use the Python 2 environment.

    Windows:

    activate py2
    

    macOS, Linux:

    conda activate py2
    
  4. Deactivate the Python 2 environment. Use your py2 environment to install packages and run programs as desired. When finished, deactivate the environment.

    Windows:

    deactivate
    

    macOS, Linux:

    conda deactivate
    
  5. Activate and use the Python 3 environment.

    Windows:

    activate py3
    

    macOS, Linux:

    conda activate py3
    

    Use the py3 environment to install and run programs as desired. When finished, deactivate the environment

  6. Deactivate the Python 3 environment.

    Windows:

    deactivate
    

    macOS, Linux:

    conda deactivate