Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Ubuntu 12.10 has Python 3.2.3 default, so does this impact existing python tools, designed to be used with older python 2.x? There was a discussion in HackerNews on the same. I'm a bit apprehensive now to guide someone in python world moving to latest 12.10 for the reason it comes with Python3.2

I'm currently installing 12.10 from 12.04. Can I work side by side on Python versions 2.x and 3.x without breaking the system? Thanks.

share|improve this question

2 Answers 2

No, this does not impact existing Python2 tools.

12.10 has Python3 installed by default, but that doesn't mean it's the "default Python". Python2 is at this point also installed by default (AFAIK), and importantly, /usr/bin/python is still a symlink to python2.7.

The transition to Python3 has been done such that it has zero effect on existing Python2 applications. 2 and 3 are parallel installable, and install their site packages in different locations.

If you want your app to use Python3, you'll have explicitly change the shebang to:

#!/usr/bin/python3

See Python 3 on Ubuntu for more details.

share|improve this answer
5  
The default python on my 12.10 install is Python 2.7.3. –  jrg Oct 18 '12 at 13:56
    
thanks that helps. And sorry I could not vote up your answer, Low on reputation now. :) –  pajju Oct 18 '12 at 14:21
2  
More importantly, there is currently no plan to ever make /usr/bin/python point to python3. Even when python 2.x is not installed by default, apps can still explicitly depend on it, and /usr/bin/python will still work for them. –  dobey Oct 18 '12 at 15:49
    
FYI, there is now a plan to make python3 the default/only Python installation for Ubuntu 14.04: wiki.ubuntu.com/Python/3 –  Jeremy Fishman Dec 30 '13 at 22:35

the hash bang should be:

#!/usr/bin/env pythonX.Y.Z

and not

#!/usr/bin/pythonX.Y.Z

This way the code will work even if python is not in /usr/bin/python but say /usr/local/bin/python or /opt/python2.7/bin/python and all is in $PATH.

It even makes the code work on OSX. IIRC it should also load the current runtime on windows[1].

[1] http://www.python.org/dev/peps/pep-0397/

share|improve this answer
2  
This looks like a comment to jderose's answer rather than an answer to the question –  gerrit Oct 18 '12 at 15:06
    
But that should be ok for ubuntu as it puts it on /usr/bin/python –  balki Oct 18 '12 at 15:21
    
You should not usr /usr/bin/env python, as it will break things like virtualenv, and hash-bang replacement when installing with different versions of python for apps that support them. You should use #!/usr/bin/python and work toward supporting python3. –  dobey Oct 18 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.