4

I am using ubuntu 14.04 and I have a program that depends on python 2.7 and does not support any of python 3.x. Ubuntu 14.04 comes with python3.4 by default. I would like to know if there is a possibility to make my program uses python2.7 instead of the default version. I thought about uninstalling python3.4, but I think it is not a good idea as some other programs may depends on it.

Thanks

Aymen
  • 41

2 Answers2

4

Check your ~/.bashrc and/or .bash_aliases to find if you have any kind of alias like this:

alias python=python3

Change it accordingly to python2.7

Andor
  • 141
2

Normally, in Ubuntu, python defaults to python2. So you probably have a

#!/usr/bin/env python3 
# 

or similar in the top of your script. Either if this is the case or if you have changed the defaults, in the header of your program, change

#!/usr/bin/env python
# 

(or the more probable python3) to

#!/usr/bin/env python2
# 

In standard Ubuntu, python should automatically point to python2:

[romano:~/tmp] % ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 jul 22 09:49 /usr/bin/python -> python2.7

so normally the above thing should not be needed. But python2 and python3 points respectively to the standard version of version 2 and 3, so if you explicitly want one version, simply tell it.

Rmano
  • 32,167