python3 traceback error

6,584

Altering the default Python interpreter in a Ubuntu derived distribution is a Bad Idea. Very many system utilities expect python to resolve to the expected version and get very unhappy when it doesn't.

Better would be (obviously shell dependent):

export PATH="${HOME}/bin:${PATH}"
ln -s /usr/bin/python2.7 $HOME/bin/python

making it your default interpreter but leaving the system utilities as they expect.

added in response to comment

My first guess as to why this didn't work is that you didn't completely clean up the changes you made.

sudo rm /usr/local/bin/python
sudo apt-get install --reinstall python

Should clear up the changes you reported here and restore the distribution default Python interpreter to be the system-wide default.

Then, remove your user alias that I suggested you make above:

rm $HOME/bin/python

And check if you still get the Python traceback when a shell command is not found. If you still get the traceback, I can't think of a standard mechanism that would cause that to happen. Therefore you'll need to give us more information about what shell you are using (presumably bash) and add the output of the commands

complete | grep python
alias | grep python
python -V

to your question.

Share:
6,584

Related videos on Youtube

wisdom
Author by

wisdom

IT Student

Updated on September 18, 2022

Comments

  • wisdom
    wisdom over 1 year

    Whenever I mistype any command in terminal instead of getting Error:Command not found I get this python message error

        Traceback (most recent call last):
      File "/usr/lib/python3.3/site.py", line 631, in <module>
        main()
      File "/usr/lib/python3.3/site.py", line 616, in main
        known_paths = addusersitepackages(known_paths)
      File "/usr/lib/python3.3/site.py", line 284, in addusersitepackages
        user_site = getusersitepackages()
      File "/usr/lib/python3.3/site.py", line 260, in getusersitepackages
        user_base = getuserbase() # this will also set USER_BASE
      File "/usr/lib/python3.3/site.py", line 250, in getuserbase
        USER_BASE = get_config_var('userbase')
      File "/usr/lib/python3.3/sysconfig.py", line 580, in get_config_var
        return get_config_vars().get(name)
      File "/usr/lib/python3.3/sysconfig.py", line 530, in get_config_vars
        _init_posix(_CONFIG_VARS)
      File "/usr/lib/python3.3/sysconfig.py", line 403, in _init_posix
        from _sysconfigdata import build_time_vars
      File "/usr/lib/python3.3/_sysconfigdata.py", line 6, in <module>
        from _sysconfigdata_m import *
    ImportError: No module named '_sysconfigdata_m'
    

    I know that after installing python3.x and trying to make it my default interpreter this error has gone this way.

    $ lsb_release -rd
    Description:    Linux Mint 14 Nadia
    Release:    14
    

    /usr/lib/command-not-found is working well also.
    Can I get back to my default python version ? simply I did

    sudo ln -sf /usr/bin/python2.7 /usr/local/bin/python
    

    is it enough to get 2.7 as default interpreter ?
    Any idea how to get rid off this hell message error ?

    • wisdom
      wisdom over 10 years
      No one is there to make this problem solved yet :(
    • wisdom
      wisdom over 10 years
      @ultrasawblade ,Have you any idea please ?
  • wisdom
    wisdom over 10 years
    making 2.7 default interpreter when call python in terminal doesn't rid this message off !! just changing used version !!Then no way to get out of this problem ?
  • wisdom
    wisdom over 10 years
    sorry for late response....but I did all steps you've mentioned and I can confirm that the problem still out there :( !, Any body has solved such this before successfully ?