1

I have Python 3.6.0 |Anaconda 4.3.0 (64-bit) installed on windows 10. I then downloaded and installed Python 2.7 | (32-bit).

My goal is to be able to open the command prompt and select either python 3.6 or 2.7 based on the environmental variable name.

Example:

python ---> Python 3.6.0 |Anaconda 4.3.0 (64-bit)
python2 ---> Python 2.7 | (32-bit)

I found a similar question here and I implemented the answer suggesting to use conda to create an ad hoc environment. However this approach leads to python 64-bit instead of 32-bit.

Can you suggest me a nice way to set up the environmental variables without messing anything up?

Federico Gentile
  • 5,650
  • 10
  • 47
  • 102

2 Answers2

1

How I solved my problem:

  1. renamed python.exe and pythonw.exe to python27.exe and pythonw27.exe (give the name you want)
  2. created enviromental variable by adding the path where .exe files are stored (ex: C:\Python27\)
  3. Followed instructions of this video to install pip. Remember to change on top this script python to whatever new environmental variable name you gave (ex: #!/usr/bin/env python27)

Note: no need to touch anaconda!

Federico Gentile
  • 5,650
  • 10
  • 47
  • 102
0

You should just be able to install them as normal then when you come to connect to one or the other just run python2 or python3 on the command line or am I missing the point of the question.

https://www.reddit.com/r/learnpython/comments/3l5pc9/using_python_3_and_python_2_on_the_same_machine/

J.Bonnell
  • 19
  • 7
  • when I open the command prompt I type python, I run python3.6 . I would like to be able to type something like python2 (or whatever else) to run python2.7.... however I don't know how to do that – Federico Gentile Oct 02 '17 at 09:20
  • so if you are running a python script in python2 you could say "python2 script.py" or if you are running it in python3 you could put "python3 script.py". when you install python these commands should be available by default even when both are installed. – J.Bonnell Oct 02 '17 at 09:22
  • if I type python2 and python3 I do not get anything but: 'python2/3' is not recognized as an internal or external command, operable program or batch file. That is my problem.... – Federico Gentile Oct 02 '17 at 09:28
  • sorry i haven't used python for a few years I think the commands may be py -2.x or py -3.x (x being for the version) – J.Bonnell Oct 02 '17 at 09:31
  • I still get the same message: 'py2.7/py3.6' is not recognized as an internal or external command, operable program or batch file. – Federico Gentile Oct 02 '17 at 09:33
  • sorry, i have just tested on a virtual machine its C:\Python27\Python.exe for python 2.7 and C:\Python36\Python.exe – J.Bonnell Oct 02 '17 at 09:39
  • yeah I think I figured it out... now the problem is pip which seems not to be working – Federico Gentile Oct 02 '17 at 09:42
  • I think my answer works fine... check it out if you are interesed – Federico Gentile Oct 02 '17 at 11:08