0

I have using Python 3.4 in my machine . I have installed the same machine Python 2.7 and do what necessary in Environment Path . In Python34 folder I have changed python.exe to python3.exe . I can use Python2.7 using python command and Python3.4 using python3 command.But there was an error usin pip :

Fatal error in launcher: Unable to create process using '"C:\Python3.4\python.exe" "C:\Python3.4\Scripts\pip.exe" install'

As you see pip still using python.exe . How can I solve this ?

Cahit Yıldırım
  • 499
  • 1
  • 10
  • 26
  • can i ask why you chose to rename the executable? if its so you can choose which version of the command line you can achive that by using `py.exe -2.7` to get version 2.7 or `py.exe 3.4` to get 3.3, you can even use `pyw.exe` instead to get that version without a console – James Kent Jan 19 '16 at 13:21
  • @JamesKent I have followed a steps in the one person comment in stackoverflow . That's why I 've changed executable file name . – Cahit Yıldırım Jan 19 '16 at 13:27
  • what steps? and you still haven't explained to what end? why did you want to change the name? what was it supposed to achieve? – James Kent Jan 19 '16 at 13:28
  • I have seen [this answer](http://stackoverflow.com/questions/20786478/how-to-run-different-python-versions-in-cmd) and changed name . The end is pip is not working now – Cahit Yıldırım Jan 19 '16 at 14:09

2 Answers2

1

I'll try to be as clear as I can here, the answer you've linked to in the comments above is specifically asking about being able to run multiple versions of python on the same machine, and being able to specify which version is used to run a script from the command line.

when python 3 is installed two executables are added to c:\Windows\ called py.exe and pyw.exe these are used by default when a python script is invoked by double clicking on it in explorer.

if no other command line arguments are set then these executables look inside the script for the shebang line which looks like #!python2 or #!python3.3 and direct the py (or pyw) executable to use that version of python to run the script, note that this could just be #!python which would use the first version found on the system (oldest first) also note that only 2 significant digits can be used (so you couldn't use #!python3.3.4). If no shebang line is found, the first version of python found will be used.

to use a specific version of python from the command line you would then have a couple of options, firstly you could specify the entire path to the python version you want, e.g. C:\Python33\python.exe scriptname.py or you can use flags.
To use a flag you would call py -3.3 scriptname.py which would call the python 3.3 interpreter and pass it the script as an argument for you.

this prevents you needing to mess about with executable names, by messing with the executable names you are breaking your own pip installation. in short there is no reason you should ever need to rename them.

James Kent
  • 5,763
  • 26
  • 50
0

I have the same error when I install python2.7 and python3.6 in my Window7. After I rename my python.exe, there was an error using pip.

If your pip is the last version,you have to reinstall your pip use the command python3 -m pip install --upgrade --force-reinstall pip.

If your pip is not the last verison ,you can just upgrade your pip with the command python3 -m pip install --upgrade pip.

NOTE. When you install pip for your python2, you hava to change the command as python2 -m pip install --upgrade --force-reinstall pip. Hope it works for you~