How to Access two different programs from PATH, both having same name in Windows 10?

1

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

Yogendra

Posted 2016-09-29T15:00:54.243

Reputation: 113

Answers

1

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

David Woodward

Posted 2016-09-29T15:00:54.243

Reputation: 1 094

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.

MikeA

Posted 2016-09-29T15:00:54.243

Reputation: 168

I don't want to rename the files because I am afraid it may affect other files that are dependent on them. – Yogendra – 2016-09-29T21:13:59.350

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 – 2016-09-29T21:19:38.353

1

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.

Ƭᴇcʜιᴇ007

Posted 2016-09-29T15:00:54.243

Reputation: 103 763