1

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
  • 3
    IF you succeed, your system will break. Many essential elements depend on python2 in 14.04. "disturbed by previous version" is a none issue, versions are called from the shebang if the file has the shebang, is executable and called without version. – Jacob Vlijm Nov 16 '16 at 13:24
  • 1
    If you want python 3, then use python3 as the command rather than python which will always be python 2. – dobey Nov 16 '16 at 13:36
  • 1
    simple answer, don't – Sergiy Kolodyazhnyy Nov 16 '16 at 18:03
6

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 :)

5

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...

First, to check if YOU have manually installated python2.7, do

apt show python2.7

Within all this infos there's a line APT-Manual-Installed: no. If this is NO you shouldn't probably uninstall it! For all packages, this rule is often true.

So, as said it isn't wise removing python2.7. I suggest to add simply an alias to your bash's configuration file, so when you'll write python in your terminal, it will be like writing python3. This is useful, but potentially can create misunderstanding.

HOW TO DO

Add

alias python=python3

at the bottom of ~/.bashrc file (or simply echo "alias python=python3" >> ~/.bashrc)

Than do:

source ~/.bashrc

from the terminal to update bash with the changes.

  • Note: apt (instead of apt-get) appeared first in 16.04 – Hannu Mar 30 at 10:11

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.