I am using anaconda and python 3.8. Now some of my codes need to be run with python 2. so I create a separate python 2.7 environment in conda like below:
after that, I installed spyder, then launcher spyder amd spyder is showing I am still using python 3.8
how do i do to use python 2.7 in spyder with a new environment?
Thanks
conda create -n py27 python=2.7 ipykernel
conda activate py27
pip install spyder
According to the documentation here , this should create a python2.7 virtual environment (29 April 2021) with spyder installed. I verified that spyder version 3.3.6 is python2.7 compatible
conda create -y -n py27 python=2.7 spyder=3.3.6
However, I could not run spyder
in the py27
environment due to conflicts that conda
failed to catch. The workaround shown by asanganuwan on this Spyder Github Issue page worked for me also
Found a workaround to use Spyder on python 2.7.
setup two virtual environments for Python 2.7 and 3.6. Launce anaconda navigator and install spyder 3.3.6 on both the environments Launch spyder on the environment with Python 3.6 Preferences-->Python Interpreter --> set the Python path for 2.7 Restart Spyder Done!
So my recommendation is next run
conda create -y -n py36 python=3.6 spyder=3.3.6
conda activate py36
spyder
And follow the last three instructions from asanganuwan.
Also you should use the conda
package manager as much as possible since it is smarter with managing requirements. When I try to use pip install spyder
after activating the environment, it warns of version conflicts and fails to start.
I suggest to first search for an anaconda 2.7 version you want, then install it explicitly, this will make resolving much faster, give you a "stable" anaconda and allow you more control while installing all anaconda packages: First:
conda search anaconda
Then select a version that has 27, in my case:
# Name Version Build Channel
anaconda custom py27_0 pkgs/main
anaconda custom py27_1 pkgs/main
anaconda custom py27h689e5c3_0 pkgs/main
anaconda custom py35_1 pkgs/main
............
anaconda 5.3.1 py27_0 pkgs/main
anaconda 5.3.1 py37_0 pkgs/main
............
anaconda 2019.10 py27_0 pkgs/main
............
I went with:
conda create -n py2 Python=2.7 anaconda==5.3.1 -y
You can manage environments from Ananconda's Navigator. https://docs.anaconda.com/anaconda/navigator/getting-started/#navigator-managing-environments
I guess you are on previous pip;
which pip
command to find out your current pip environment.pipX install spyder
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.