I have both Python 3.3 and Python 2.7 installed on my computer. The python 3.3 works fine, but when I try to run something using python 2.7, it is still referencing python 3.3.
For Example: if I type F:\Python33\python33.exe test1.py
, it will run with 3.3 and work fine, but if I type F:\Python27\python27.exe test1.py
it gives this error:
File "F:\PYTHON33\LIB\site.py", line 173
file=sys.stderr)
^
SyntaxError: invalid syntax
Note: I have renamed the Python 2.7 and 3.3 .exe's to python27.exe and python33.exe respectively.
Any help would be appreciated, Thank you.
Switch between different versions 10. You can repeat the above steps and install different versions of python as you want and set priority and use them as needed. To use these python versions with IDE, go to your IDE's interpreter settings and there you can see the different versions of python available on your system.
If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.
Installing multiple versions of Python You can download the installer for Python 2.7 here. You can learn to install python2 on Windows here. You can download the installer for Python 3.10 here. You can learn to install python3 on Windows here.
Install that version using "make install". Install all other versions using "make altinstall". For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.
Google search results have returned a few useful resources that answer your problem.
The Python Documentation (http://docs.python.org/3.3/using/windows.html#python-launcher-for-windows) gives a quick overview for running multiple versions on the same machine.
The first option would be to include your python version in the file you wish to execute using something along the lines of
#! python
Your code here
To execute in Python 2, or
#! python3
Your code here
For running the code in your Python 3 version. Then you would simply use "python yourscript.py" and the python version would be specified by the Python script.
There are multiple other questions which may address the problem you are facing:
How to install both Python 2.x and Python 3.x in Windows 7
Or for Ubuntu 13: Ubuntu 13.04 Install and running Python 3 at the same time than Python 2.7.x
Or for Mac using Homebrew: How can I use Homebrew to install both Python 2 and 3 on Mac?
And a video reference for Mac without Homebrew: http://www.youtube.com/watch?v=c9LlK2iu7OA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With