10/17/11

Using python3.0 under standard ubuntu python2.6.6 installation

I have default python2.6.6 installation on my machine, but I want to use the new version of the python3.0 for some scripts. The script.py is simply printing the Python version used, but with shebang version specified.

#!/usr/bin/python3.1
import platform
print(platform.python_version())



So, the results are following.
1. Starting the script from command line python test.py will give us the default version

2. Starting the script from command line with specified the version python3.1 test.py will give us the 3.1 python version.

3. If we remove the shebang line, so the script will behave absolutely the same, but ./test.py will fail, when launching with shebang line ./test.py - it will give us the correct 3.1 version. Launching without shebang line this way python3.1 test.py also will give us the 3.0 version.

No comments:

Post a Comment