Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active September 5, 2023 04:55
Show Gist options
  • Save stormwild/f89d48b34aa3255903f8d59bae98c639 to your computer and use it in GitHub Desktop.
Save stormwild/f89d48b34aa3255903f8d59bae98c639 to your computer and use it in GitHub Desktop.
Creating python2 environment in conda

Conda Environment

Create and activate an environment

conda create -n python2 python=2.7 anaconda
source activate python2

Deactivate environment

source deactivate python2

List environments

conda env list

Remove an environment

conda env remove --name python2

When using Spyder, Jupyter in Anaconda

Ensure you have at least Anaconda 4.1.o or higher

conda --version

If not update conda

conda update conda

Check if nb_conda_kernels is installed

conda list

If not install

conda install nb_conda_kernels

If you’re running Jupyter on Python 3, you can set up a Python 2 kernel like this:

python2 -m pip install ipykernel

python2 -m ipykernel install --user

Alternatively, if you are using Python 2 and want a separate Python 3 environment please type the following

conda create -n py36 python=3.6 ipykernel

py36 is the name of the environment. You could literally name it anything you want. If you are using Python 3 and want a separate Python 2 environment, you could type the following.

conda create -n py27 python=2.7 ipykernel

Open new terminal.

Launch Jupyter and see the new environments listed.

References

@HannoSpreeuw
Copy link

Perhaps

source activate python2  ---> conda activate python2
source deactivate python2 ---> conda deactivate

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment