I am a software developer, designer and cyclist.
On this site I leave interesting findings and opinions.

Latest blog entry

No module named '_sysconfigdata_m'

Sunday, 19th April 2015, 2045hrs

Linux | Python | Ubuntu

After an update of your Ubuntu, Mint, or any dervative thereof (and very likely after installing a new Python release) you might encounter a stack trace on your console at regular intervals:

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

When you mistyped a command in you console, your system will start a script which will explain you that the command you entered (like dokker) was not found, but that there's another command you might want to try:

user@box:~$ dokker
No command 'dokker' found, did you mean:
Command 'docker' from package 'docker' (universe)
dokker: command not found
user@box:~$

This handy utility is in fact a Python script. It is called command-not-found and you can find it in /usr/lib. The command-not-found call itself is made by /etc/bash.bashrc. In this file the wrong Python vm is started.

Solution

This is easy to fix. At the end of the /etc/bash.bashrc file you'll see

python /usr/lib/command-not-found -- $1

Just replace it with

/usr/lib/command-not-found -- $1

That will do the trick.

Very likely installing a new distribution based Python (and cleaning up any Python versions you've built youself) will also fix this problem.

Note

The _sysconfigdata_m.py[c] file is used by the sysconfig module. This module is introduced in Python since 3.2 and provides access to Python’s configuration information like the list of installation paths and the configuration variables relevant for your platform.

The command python -m sysconfig shows you most of its features.

Latest stuff from my blog