Nick Duddy
Nick Duddy

Reputation: 1000

Ubuntu 'Failed to import the site module' error message

I get the following error message below. When I try to run a python file with the command python3 training.py

I found a potential solution here but when I went to make the suggested change it appeared that my machine had what was considered the correct setup.

To clarify, I have did significant research and none of the following fixes work

Any suggestions to what it could be and how to fix it?

Failed to import the site module
Traceback (most recent call last):
  File "/usr/lib/python3.5/site.py", line 580, in <module>
    main()
  File "/usr/lib/python3.5/site.py", line 566, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python3.5/site.py", line 253, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_m import *
ImportError: No module named '_sysconfigdata_m'

Upvotes: 2

Views: 11425

Answers (3)

Marko Panushkovski
Marko Panushkovski

Reputation: 63

I also had similar issue on windows. I was installing python with PyCharm after I erased other version of python and the program looked for site-packages in the old location. I just installed the pip.exe file by double click from the Scripts folder of new python that I installed.

Upvotes: 0

Kenan
Kenan

Reputation: 14124

I had a similar issue but on windows, so Im not sure if this will help. Turns out I has some environment variables that were causing the terminal to screw it.

I downloaded anaconda but had PYTHONHOME and PYTHONSCRIPTS as environmental variables. I deleted those since anaconda creates it's own environmental variables for the terminal to use. Problem solved after that.

Note: Be sure to restart after deleting

Upvotes: 0

Nick Duddy
Nick Duddy

Reputation: 1000

I couldn't find a solution to this. I decided to upgrade to Ubuntu 17.x and the issues is now gone.

Upvotes: 1

Related Questions