0

On my PC, Python 2 and 3 are installed – a query of the versions, using the terminal, outputs the following:

$ python2 --version 
Python 2.7.14

$ python3 --version
Python 3.6.3

I would like to learn Python 3, and I use Geany under Xubuntu 17.10 as my development environment. The shebang line reads as follows:

#!/usr/bin/env python3

I do a query for the python version in my little program, the output tells me that Python 2 interpreter is used:

print(sys.version_info)
sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0)

How can that be, as I specify Python 3 in the Shebang? I also wrote the path to the Python 3 interpreter there, but that did not help.

So, here’s my concrete question: How can I achieve that my program gets interpreted by Python 3, and not 2? I could not find an answer in the WWW – I seem to be the only person having this problem. Deinstalling Python 2 is no option, as many applications need this version 2. For any hints where I could start; I’d be very thankful.

1

You have to modify the file /usr/share/geany/filetypes.python by replacing the 2 occurrences of <=python> with <=python3>:

sudo sed -i 's/=python/=python3/g' /usr/share/geany/filetypes.python

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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