I have python 3.3 as my default python on my computer and want to write a code that involves libraries only compatible with python 3.2, which I have on my computer already. Is there a way without changing the path variable that will allow me to do this or does python do this automatically?
2 Answers
If you are using Linux, you can specify the python version to be used at the top of your code. For example on my system:
#!/usr/bin/python
print "Hello"
will be passed to the default python interpreter, while:
#!/usr/bin/python3.2
print "Hello"
will be passed to python 3.2. In windows the #! line is ignored so the correct interpreter must be specified when calling the script e.g:
C:\python32\python script.py
rather than just:
python script.py
Comments
It is surprising if the library is really broken by the 3.2 to 3.3 upgrade. This was a relatively minor upgrade, and nothing (much?) was taken away. I would try to see if the package actually runs in 3.3 first of all.
On Unix you can use a shebang line.
#!/usr/bin/env python32
to direct the script to use a particular version.