3

I added addresses of python 2.7, and Anaconda 4.1.1(Python 3.5) to PATH variable in Windows 10, whenever I run "python" from cmd, program which was added earlier is executed.How can I access both of them depending on my choice without altering name of either

3 Answers 3

4

Since you specified "without altering the name of either", one possible solution is to make a link (see mklink) to the files somewhere in your path (or more preferably in the same folder as the original file) and that link can have a different name. Then you can use the name of that link to distinguish the two versions, but the file will still have its original name.

Example (run cmd.exe as an administrator - required for mklink):

mklink "python 2.7\python2_7.exe" "python 2.7\python.exe"
mklink "anaconda 4.1.1\python3_5.exe" "anaconda 4.1.1\python.exe"

CD \
python2_7.exe
python3_5.exe
2

Either specify the path so you call the proper one or, if you don't want to rename the executable itself, make a bath file with a custom name (ie: Python34.bat) that runs the Python 3.4 exe by specifying its full path, and then put the batch file into a location in your Path.

1

You can't if the two programs you want to run have the exact same name. What you are experiencing is how the PATH variable works. There shouldn't be a reason why you can't rename one program or other other, i.e. python -> python27 or python -> python35. Then you can reliably start either one.

2
  • I don't want to rename the files because I am afraid it may affect other files that are dependent on them.
    – Yogendra
    Commented Sep 29, 2016 at 21:13
  • I can't think of a case where that might be an issue, but it doesn't really matter. The other answers suggesting links or bat files will work just the same.
    – MikeA
    Commented Sep 29, 2016 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .