I'm trying to write a simple Python
script using Geany
. This IDE will automatically compile the code I write but I'm not sure which version of Python
it is using. If I enter python --version
in the command line I get:
Python 2.7.3
but if I enter python3
I get:
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Does Ubuntu come with both versions? If so, which one is Geany
using to compile?
Ubuntu comes with both versions, yes. The
python
command will always point to a Python 2.x version, andpython3
will always point to the default Python 3.x version. Thepython
command will never point to Python 3.x.I'm not sure what Geany uses exactly, but I would suspect it uses Python 2.x (and thus probably puts
#!/usr/bin/python
(or should put if it uses/usr/bin/env python
instead), in the scripts it generates.Try running
import sys;print(sys.version_info)
from inside geany.You can use:
To find out what version of python you are running.
Of course due to changes in python 3
print
is now a function so this won't work for version 3. In that case you would use: