'Python2 doesn't work when both python3.8 and python2.7 are installed on Anaconda3
I installed Anaconda and used Python3.8.8 as the base environment, now I create a new environment named py27 to install python2.7, but it doesn't work.
Here are the details
(base) C:\Windows\System32>conda env list
# conda environments:
#
base * C:\ProgramData\Anaconda3
pix2vox C:\Users\10531\.conda\envs\pix2vox
py27 C:\Users\10531\.conda\envs\py27
(base) C:\Windows\System32>python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(base) C:\Windows\System32>conda activate py27
(py27) C:\Windows\System32>python
File "C:\ProgramData\Anaconda3\lib\site.py", line 178
file=sys.stderr)
^
SyntaxError: invalid syntax
(py27) C:\Windows\System32>
My environment variable PATH contains
C:\ProgramData\Anaconda3;
C:\ProgramData\Anaconda3\Scripts;
C:\ProgramData\Anaconda3\Library\mingw-w64\bin;
C:\ProgramData\Anaconda3\Library\usr\bin;
C:\ProgramData\Anaconda3\Library\bin;
I want to use both python3.8 and python2.7 simultaneously, please help me, thanks!
Solution 1:[1]
I fixed it.
Delete the
PYTHONHOMEenvironment variable, I set it asC:\ProgramData\Anaconda3;before.Delete
C:\ProgramData\Anaconda3\Library\mingw-w64\bin;
C:\ProgramData\Anaconda3\Library\usr\bin;
C:\ProgramData\Anaconda3\Library\bin;
in Path, I didn't know if it works, but I did it.
- Add new entries
C:\Users\10531\.conda\envs\py27;
C:\Users\10531\.conda\envs\py27\Scripts;
in PATH.
- Rerun the terminal.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | S DQ |
