LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   python3 -V returns Python 2.7.12, can't get python3 to work. (https://www.linuxquestions.org/questions/ubuntu-63/python3-v-returns-python-2-7-12-cant-get-python3-to-work-4175650241/)

gene_ 03-15-2019 11:31 AM

python3 -V returns Python 2.7.12, can't get python3 to work.
 
I have been writing some code in Python3 using tkinter for graphics, and also python2 to upload to trinket.io. I am not sure what caused the python3 install to break, but now I can't get any code to find it,
typing $python3 -V returns Python 2.7.12.
Typing $which python3 returns /usr/bin/python3.
I have tried uninstalling, reinstalling, upgrading, installing pip, everything I can find online. I think I trashed to original python3 install and the links and path. Not sure where to start to figure out how to get a working install.

I have gotten as far as finding one PPA I can't uninstall, not sure if it's related.

$ sudo apt-add-repository --remove ppa:bhdouglass/indicator-remindor

returns:

File "/usr/bin/lsb_release", line 64
print("No LSB modules are available.", file=sys.stderr)
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/usr/bin/apt-add-repository", line 22, in <module>
sys.stdout.detach(), encoding="UTF-8", line_buffering=True)
AttributeError: 'file' object has no attribute 'detach'

pan64 03-18-2019 03:07 AM

so what is /usr/bin/python3 ?

gene_ 03-18-2019 07:23 AM

when I go to the /usr/bin directory and type python3 -V I get Python 2.7.12. How can I actually check the file python3 to see what binary it is?

pan64 03-18-2019 07:30 AM

Code:

ls -l /usr/bin/python3
which python3
type python3
file /usr/bin/python3
readlink -f /usr/bin/python3

or something similar

gene_ 03-18-2019 08:01 AM

they all say python3.5

whenever I run any python or python3 command, python 2.7.12 is always used. I can't seem to access python3 or any other version.

pan64 03-18-2019 08:06 AM

would be nice to post the exact result, not an explanation

gene_ 03-18-2019 08:08 AM

$ python3 -V
Python 2.7.12
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Mar 23 2016 /usr/bin/python3 -> python3.5
$ which python3

/usr/bin/python3
$
$ type python3
python3 is hashed (/usr/bin/python3)
$ type python3
python3 is hashed (/usr/bin/python3)
$ readlink -f /usr/bin/python3
/usr/bin/python3.5
$

pan64 03-18-2019 08:13 AM

ok, thanks. The next one is:
/usr/bin/python3.5 --version

gene_ 03-18-2019 08:16 AM

$ readlink -f /usr/bin/python3
/usr/bin/python3.5
$ /usr/bin/python3.5 --version
Python 2.7.12
$

pan64 03-18-2019 08:24 AM

What OS is it? Which python versions are installed ?
also what will say: ls -l /usr/bin/python*

gene_ 03-18-2019 08:29 AM

$ lsb_release -a
File "/usr/bin/lsb_release", line 64
print("No LSB modules are available.", file=sys.stderr)
^
SyntaxError: invalid syntax
$


$ ls python*
python python2-config python3.5m python-config
python2 python2-dbg python3.5m-config python-dbg
python2.7 python2-dbg-config python3-config python-dbg-config
python2.7-config python3 python3m
python2.7-dbg python3.5 python3m-config
python2.7-dbg-config python3.5-config python-argcomplete-check-easy-install-script3
$

gene_ 03-18-2019 08:30 AM

It is Ubuntu 16.04, but I can't get the $ lsb_release -a command to work

gene_ 03-18-2019 08:32 AM

$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 9 Nov 23 2017 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 9 Nov 23 2017 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3829036 Nov 23 2017 /usr/bin/python2.7
lrwxrwxrwx 1 root root 31 Nov 23 2017 /usr/bin/python2.7-config -> i386-linux-gnu-python2.7-config
-rwxr-xr-x 1 root root 5830736 Nov 23 2017 /usr/bin/python2.7-dbg
lrwxrwxrwx 1 root root 35 Nov 23 2017 /usr/bin/python2.7-dbg-config -> i386-linux-gnu-python2.7-dbg-config
lrwxrwxrwx 1 root root 16 Nov 23 2017 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 13 Nov 23 2017 /usr/bin/python2-dbg -> python2.7-dbg
lrwxrwxrwx 1 root root 20 Nov 23 2017 /usr/bin/python2-dbg-config -> python2.7-dbg-config
lrwxrwxrwx 1 root root 9 Mar 23 2016 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 3829036 Feb 17 13:53 /usr/bin/python3.5
lrwxrwxrwx 1 root root 31 Nov 12 09:26 /usr/bin/python3.5-config -> i386-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 3829036 Feb 17 13:53 /usr/bin/python3.5m
lrwxrwxrwx 1 root root 32 Nov 12 09:26 /usr/bin/python3.5m-config -> i386-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root 16 Mar 23 2016 /usr/bin/python3-config -> python3.5-config
lrwxrwxrwx 1 root root 10 Mar 23 2016 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root 17 Mar 23 2016 /usr/bin/python3m-config -> python3.5m-config
-rwxr-xr-x 1 root root 2553 Feb 10 2016 /usr/bin/python-argcomplete-check-easy-install-script3
lrwxrwxrwx 1 root root 16 Nov 23 2017 /usr/bin/python-config -> python2.7-config
lrwxrwxrwx 1 root root 13 Nov 23 2017 /usr/bin/python-dbg -> python2.7-dbg
lrwxrwxrwx 1 root root 20 Nov 23 2017 /usr/bin/python-dbg-config -> python2.7-dbg-config
$

pan64 03-18-2019 10:05 AM

interesting, your python3 and python2 binaries are the same.
You can check it by:
Code:

md5sum /usr/bin/python2.7 /usr/bin/python3.5
# also what will say:
dpkg -l | grep 'python.*default'

lsb_release is a python3 script, probably that is a problem now.
I would [try to] force reinstall python3.

gene_ 03-18-2019 10:33 AM

ok, thanks. That is what I thought, but I didn't know how to find out for sure. I also don't know how to fix it, everything seems to be pretty hosed.


All times are GMT -5. The time now is 04:35 PM.