1

I installed python 3.4 and python 3.5 to C:\Python34 and C:\Python35 respectively. and I created two bat files refering to these executables namely python.bat and python35.bat and added them to my PATH. so that I can get

C:\>python -V 
Python 3.4.3

C:\>python35 -V
Python 3.5.1

C:\>pip

This works fine for me, except when I want to call PIP because it is actually inside the PythonXX\Scripts\ folder.

Is there an easy way to get away with calling pip and other scripts from cmd, without typing C:\>Python34\Scripts\pip or C:\>Python35\Scripts\pip each time?

(Note: pip is not the only file I want to run from Scripts folder. can I do the alias for the Scripts directory?)

martineau
  • 119,623
  • 25
  • 170
  • 301
Ahmad Abdelghany
  • 11,983
  • 5
  • 41
  • 36
  • couldn't you do the exact same thing than with the python executable? – tglaria Jan 19 '16 at 12:50
  • 1
    Do something like `set PATH=C:\Python35\Scripts;%PATH%` in your bat file – J.J. Hakala Jan 19 '16 at 12:51
  • @J.J.Hakala would that be a permanent change or for a single session only? (If it's permanent, you would be updating `PATH` for each time you load the bat file – tglaria Jan 19 '16 at 12:53
  • @Zetys I was hoping to find a solution on the directory level, so that I dont need to rename all executables inside Scripts (pip and others) – Ahmad Abdelghany Jan 19 '16 at 13:00
  • 1
    FWIW, I have a `pip2.7.exe` in my `c:\Python\Scripts` and a `pip3.5.exe` in my `c:\Python3\Scripts` folder so I can be explicit about which one I want at the command line. – martineau Jan 19 '16 at 13:56
  • see [_Permanent Windows command-line aliases with doskey and AutoRun_](http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html) to learn how to make your aliases load automatically. – martineau Jan 19 '16 at 14:13
  • Use the py.exe launcher that installs in `%SystemRoot%`? For example, `py -3.4 -m pip` and `py -3.5 -m pip`. Nothing in `PATH`. No batch files. No configuration. Use shebangs in your scripts such as `#!python3.5` and `#!python3` (latest). Double-click on or run .py scripts directly. py.exe also recognizes an active `venv` virtual environment, but in that case `python` and `pip` work just as well. The only thing you may want to configure is adding `.PY` to `PATHEXT` to run scripts without have to type the .py extension. – Eryk Sun Jan 20 '16 at 01:39
  • The answer is here http://stackoverflow.com/questions/4583367/how-to-run-multiple-python-version-on-windows – Kenly Jan 21 '16 at 10:42

2 Answers2

1

You can create symbolic links:

for %A in (c:\Python34\Scripts\*.exe) do mklink C:\Windows\System32\%~nA34.exe %A

Then call pip with pip34. Do the same thing with other python versions.

Community
  • 1
  • 1
Kenly
  • 24,317
  • 7
  • 44
  • 60
  • is there a way to make an alias for the Scripts directory, so it works for all executables inside it? – Ahmad Abdelghany Jan 19 '16 at 13:10
  • not exactly what i was hoping for as it still alias the .exe files not the directory. (for example won`t work if .exe is in sub directory of Scripts). still useful though. thanks +1 – Ahmad Abdelghany Jan 19 '16 at 14:18
0

You could set up some aliases

doskey pip34=C:\python34\scripts\pip
doskey pip35=C:\python35\scripts\pip

I don't have a windows shell to test this on, but from what I've read it "should" work.

John
  • 13,197
  • 7
  • 51
  • 101
  • There are multiple files inside scripts. so I am searching for a solution for the whole directory. I have updated the question to clarify this point – Ahmad Abdelghany Jan 19 '16 at 13:07