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

  • No one is there to make this problem solved yet :( – wisdom Oct 23 '13 at 15:52
  • @ultrasawblade ,Have you any idea please ? – wisdom Oct 29 '13 at 18:46

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.

  • 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 Oct 20 '13 at 15:21
  • 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 ? – wisdom Oct 20 '13 at 19:07
  • for commands you asked for the output, first two no output there just succeeded the last one python -V gives Python 2.7.3 – wisdom Oct 20 '13 at 19:09

This is actually a bug in the ubuntu distribution, as discussed on stackoverflow and launchpad.

The fix is to patch your /etc/bash.bashrc file, changing the line python /usr/lib/command-not-found -- $1 to usr/lib/command-not-found -- $1.

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.