I'm doing a learn python the hardway tutorial, and they are using python2.7 I got it downloaded but unable to switch back from 3.3 to 2.7 I manipulated PATH variable, adding C:\Python27 but this was no use any other suggestion?
Asked
Active
Viewed 130 times
0
-
Add 2.7 path before 3.3 that will do. – Rahul Apr 21 '17 at 05:29
-
I'd recommend that the official python documentation over python the "hard way" – OneCricketeer Apr 21 '17 at 05:36
-
1How are you running Python? Are you just typing `python` or are you running a script? With a "shebang" line like `#!/usr/bin/python` Windows should pick Python 2 by default for scripts (using the python launcher program `py.exe`). – Blckknght Apr 21 '17 at 06:14
2 Answers
0
Rename the python interpreter executables to their respective versions. The OS is just executing the first 'python' executable it finds in the path, which is probably the 3.x version. So in command line, you can type python2 or python3 to select the version of interpreter you want.

Joe D
- 378
- 1
- 9
-
If you're creating versioned executables, it's much better to create a symbolic link in the installation directory via `mklink python3.exe python.exe`. This will survive an in-place upgrade, and it won't break existing usage of "python.exe", such as command templates for the .py file association or py.exe launcher. – Eryk Sun Apr 21 '17 at 05:35
0
Another option is.
you can create virtual environment for python 2.7 version. And Activate the environment. And use your virtual env for your python 2.7 learning.
username@mypc:~/dev/learn-code$ virtualenv myenv -p /usr/bin/python
Already using interpreter /usr/bin/python
New python executable in /home/username/dev/learn-code/myenv/bin/python
Installing setuptools, pip, wheel...done.
username@mypc:~/dev/learn-code$
username@mypc:~/dev/learn-code$
username@mypc:~/dev/learn-code$ source myenv/bin/activate
(myenv) username@mypc:~/dev/learn-code$
(myenv) username@mypc:~/dev/learn-code$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
hello
>>>
- Setting up in windows environment also similar. see this link