1

I'm using python 3.6.4 and 2.5.17 windows 10 and when I try to run any code, it only runs using version 2.7.15 I've tried to add to the first line of my code:

#! python3

or

#! python2

and nothing happened and I also tried to use

py -the number of versions

i have this output:

'py' is not recognized as an internal or external command, operable program or batch file.

and if I wanna download anything using pip or pip3 command for python 3.6.4 it only installs it for python 2.7.15. I've checked the environment variables I have python 2.7.15 and 3.6.4 included Can anyone one help me?

edit:

i have the py launcher installed on my PC :

see here

and when i try to run it :

see here

and python files are included in the system variables

see here

and the python 3.6.4 directory only contain thous files :

see here

so what i have to do to run two versins of python now ?? and how to run scripts in atom ?

Mosa Abbas
  • 139
  • 1
  • 1
  • 16
  • You either skipped the option to install the `py` launcher at install time, or you changed your environment variables in some way after doing so. If you just re-run the 3.6.4 installer, I believe it gives you the option to modify your existing installation instead of reinstalling. And if you then enable the option to install `py`, that should fix it. – abarnert Aug 08 '18 at 16:57
  • 1
    first line should be like this #!/bin/env/python3 or #!/bin/env/python2. – kartheek Aug 08 '18 at 16:57
  • @user6924051 Not for Windows. You can optionally do that for cross-platform scripts, but for scripts meant to be run only on Windows via `py`, what the OP has written is exactly what’s recommended. – abarnert Aug 08 '18 at 16:58
  • 2
    Possible duplicate of [How to run multiple Python versions on Windows](https://stackoverflow.com/questions/4583367/how-to-run-multiple-python-versions-on-windows) – whoosis Aug 08 '18 at 17:04
  • @abarnert actually i have the python launcher installed and i don't know what to do – Mosa Abbas Aug 08 '18 at 17:22
  • The error message "'py' is not recognized as an internal or external command" means you don't have it installed, or at least it isn't on your PATH. If you do have it installed, you don't have a question. – abarnert Aug 08 '18 at 17:58
  • @abarnert how can i add the launcher to my path ?? – Mosa Abbas Aug 08 '18 at 18:02
  • The installer should do that for you, unless you tell it not to. See [PEP 397](https://www.python.org/dev/peps/pep-0397/) for details on what location it picks, how it stores that in the registry, etc. – abarnert Aug 08 '18 at 19:01
  • This answer will get taken down because I am not answering your question completely and I do not have enough reputation to comment, but look into setting up a virtual machine to run different versions of python. I hope this can help you at least a little bit, good luck! [This may help](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/) – Tre P. Aug 08 '18 at 16:57
  • 1
    @whoosis i've seen that question it was not helpful – Mosa Abbas Aug 08 '18 at 19:03

1 Answers1

3

Not sure about windows, but if you have installed Anaconda prompt for windows, then you can install different versions of python on Anaconda prompt and give them specific names. Like for me, I have python3.6.5 version named as base version and the python2.7 version as py27. Whenever I need to switch to either of them, I just use activate command:

activate py27 //to switch to python2.7

activate base    //to switch to python3.6.5

This automatically switches me to specified version of python in the anaconda prompt and then you can work it whichever way you like.

CodeHunter
  • 2,017
  • 2
  • 21
  • 47