简体   繁体   中英

Python2 and Python3 both in windows 10

I used Anaconda for python.

python2 is installed in D:\Python\Anaconda2

python3 is installed in D:\Python\Anaconda3

python3 is the default.

created two environmental variables with name: python2 and python2 and selected respective python.exe from different folder respectively.

my setup.py supports only python2.

when i run command from cmd python setup.py install it says it does not support. If I rename D:\Python\Anaconda2\python.exe to D:\Python\Anaconda2\python2.exe and change the environment path file accordingly it works. But I dnt want to change the file name (as it may break other apps, like conda says unable to create process, etc).

Windows 10 Pro, 64 bit. setup.py location: E:\Program Files\IBM\ILOG\CPLEX_Studio1251\cplex\python\x64_win64

  1. How to overcome this? Want python2 setup.py install for python2 compiler and python3 setup.py install for python3 compiler, without renaming.

  2. How to install setup.py by running D:\Python\Anaconda2\python.exe ?

I'm not sure whether this directly answers your question,but anaconda manages environments for you. Reference

You should be able to type into your Anaconda prompt to create your environment:

conda create --name pyenv python=2.7

and then list your environments:

conda info --envs

and lastly activate your environment python 2 or python 3 environments:

activate pyenv

These separate environments with their own versions of python are saved in the anaconda folder under the envs folder

/Anaconda3/envs/pyenv/python

Here is how you can use both python2 and python3 in windows 10

Enter windows keys and type "Edit the system environment variables"

  • Click on Path and enter Edit button. 在此处输入图像描述
  • Add path to both version of python. (Important) Here i have listed python3 and python2 in order because i want to see version 2 by python --version and version3 by python3 --version. 在此处输入图像描述
  • Go to C:\python310 in windows (or whatever the name is for python3) and update executable file to python3 instead of python. 在此处输入图像描述

Save and exit.

Now,

  • python --version // python 2
  • python3 --version // python 3

If you want it otherwise, update executable file of python2 to python2 instead of python. And update PATH variables to list python2 and python3 in order.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM