Ubuntu – How to uninstall python 2.7 and reinstall 3.5 in Ubuntu 14.04

python

I d like to ask a clean removal method, so that python 3 will not be diturbed by previous version.
I am not sure how the python2.7 be installed, because it was not me who did it. And i am totally new in Linux, so I really not sure what should I do…

Here is the information when I check the python version.
Thanks!! 🙂

administrator@TUBVLMF-AWR163:~$ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/bin/anaconda/lib/python2.7/site.pyc matches /usr/bin/anaconda/lib/python2.7/site.py
import site # precompiled from /usr/bin/anaconda/lib/python2.7/site.pyc
# /usr/bin/anaconda/lib/python2.7/os.pyc matches /usr/bin/anaconda/lib/python2.7/os.py
import os # precompiled from /usr/bin/anaconda/lib/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /usr/bin/anaconda/lib/python2.7/posixpath.pyc matches /usr/bin/anaconda/lib/python2.7/posixpath.py
import posixpath # precompiled from /usr/bin/anaconda/lib/python2.7/posixpath.pyc
# /usr/bin/anaconda/lib/python2.7/stat.pyc matches /usr/bin/anaconda/lib/python2.7/stat.py
import stat # precompiled from /usr/bin/anaconda/lib/python2.7/stat.pyc
# /usr/bin/anaconda/lib/python2.7/genericpath.pyc matches /usr/bin/anaconda/lib/python2.7/genericpath.py
import genericpath # precompiled from /usr/bin/anaconda/lib/python2.7/genericpath.pyc
# /usr/bin/anaconda/lib/python2.7/warnings.pyc matches /usr/bin/anaconda/lib/python2.7/warnings.py
import warnings # precompiled from /usr/bin/anaconda/lib/python2.7/warnings.pyc
# /usr/bin/anaconda/lib/python2.7/linecache.pyc matches /usr/bin/anaconda/lib/python2.7/linecache.py
import linecache # precompiled from /usr/bin/anaconda/lib/python2.7/linecache.pyc
# /usr/bin/anaconda/lib/python2.7/types.pyc matches /usr/bin/anaconda/lib/python2.7/types.py
import types # precompiled from /usr/bin/anaconda/lib/python2.7/types.pyc
# /usr/bin/anaconda/lib/python2.7/UserDict.pyc matches /usr/bin/anaconda/lib/python2.7/UserDict.py
import UserDict # precompiled from /usr/bin/anaconda/lib/python2.7/UserDict.pyc
# /usr/bin/anaconda/lib/python2.7/_abcoll.pyc matches /usr/bin/anaconda/lib/python2.7/_abcoll.py
import _abcoll # precompiled from /usr/bin/anaconda/lib/python2.7/_abcoll.pyc
# /usr/bin/anaconda/lib/python2.7/abc.pyc matches /usr/bin/anaconda/lib/python2.7/abc.py
import abc # precompiled from /usr/bin/anaconda/lib/python2.7/abc.pyc
# /usr/bin/anaconda/lib/python2.7/_weakrefset.pyc matches /usr/bin/anaconda/lib/python2.7/_weakrefset.py
import _weakrefset # precompiled from /usr/bin/anaconda/lib/python2.7/_weakrefset.pyc
import _weakref # builtin
# /usr/bin/anaconda/lib/python2.7/copy_reg.pyc matches /usr/bin/anaconda/lib/python2.7/copy_reg.py
import copy_reg # precompiled from /usr/bin/anaconda/lib/python2.7/copy_reg.pyc
# /usr/bin/anaconda/lib/python2.7/traceback.pyc matches /usr/bin/anaconda/lib/python2.7/traceback.py
import traceback # precompiled from /usr/bin/anaconda/lib/python2.7/traceback.pyc
# /usr/bin/anaconda/lib/python2.7/sysconfig.pyc matches /usr/bin/anaconda/lib/python2.7/sysconfig.py
import sysconfig # precompiled from /usr/bin/anaconda/lib/python2.7/sysconfig.pyc
# /usr/bin/anaconda/lib/python2.7/re.pyc matches /usr/bin/anaconda/lib/python2.7/re.py
import re # precompiled from /usr/bin/anaconda/lib/python2.7/re.pyc
# /usr/bin/anaconda/lib/python2.7/sre_compile.pyc matches /usr/bin/anaconda/lib/python2.7/sre_compile.py
import sre_compile # precompiled from /usr/bin/anaconda/lib/python2.7/sre_compile.pyc
import _sre # builtin
# /usr/bin/anaconda/lib/python2.7/sre_parse.pyc matches /usr/bin/anaconda/lib/python2.7/sre_parse.py
import sre_parse # precompiled from /usr/bin/anaconda/lib/python2.7/sre_parse.pyc
# /usr/bin/anaconda/lib/python2.7/sre_constants.pyc matches /usr/bin/anaconda/lib/python2.7/sre_constants.py
import sre_constants # precompiled from /usr/bin/anaconda/lib/python2.7/sre_constants.pyc
# /usr/bin/anaconda/lib/python2.7/_sysconfigdata.pyc matches /usr/bin/anaconda/lib/python2.7/_sysconfigdata.py
import _sysconfigdata # precompiled from /usr/bin/anaconda/lib/python2.7/_sysconfigdata.pyc
# zipimport: found 13 names in /usr/bin/anaconda/lib/python2.7/site-packages/runipy-0.1.0-py2.7.egg
# zipimport: found 135 names in /usr/bin/anaconda/lib/python2.7/site-packages/setuptools-3.6-py2.7.egg
import encodings # directory /usr/bin/anaconda/lib/python2.7/encodings
# /usr/bin/anaconda/lib/python2.7/encodings/__init__.pyc matches /usr/bin/anaconda/lib/python2.7/encodings/__init__.py
import encodings # precompiled from /usr/bin/anaconda/lib/python2.7/encodings/__init__.pyc
# /usr/bin/anaconda/lib/python2.7/codecs.pyc matches /usr/bin/anaconda/lib/python2.7/codecs.py
import codecs # precompiled from /usr/bin/anaconda/lib/python2.7/codecs.pyc
import _codecs # builtin
# /usr/bin/anaconda/lib/python2.7/encodings/aliases.pyc matches /usr/bin/anaconda/lib/python2.7/encodings/aliases.py
import encodings.aliases # precompiled from /usr/bin/anaconda/lib/python2.7/encodings/aliases.pyc
# /usr/bin/anaconda/lib/python2.7/encodings/utf_8.pyc matches /usr/bin/anaconda/lib/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/bin/anaconda/lib/python2.7/encodings/utf_8.pyc
Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun  2 2014, 12:34:02) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
dlopen("/usr/bin/anaconda/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /usr/bin/anaconda/lib/python2.7/lib-dynload/readline.so

Best Answer

By default in latest Ubuntu release python and python3 are already included and if you completely remove python 2.7 it may break your system type in terminal

python3

to open python 3 interpreter and when you run your scripts type

python3 Scriptname

and if not already included type in terminal

sudo apt-get update && sudo apt-get install python3

have fun :)

Related Question