Heasummn
Heasummn

Reputation: 93

Running Python 2.7 gives error

File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()

This is the error I receive running ubuntu 14.04 using Python.

Python 3 works fine, and this error occurs when running a script, or using the Python interpreter.

Full Trace:

File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 524, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 408, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

This error seems like a Path error, I just recently installed wxPython as well, but made no changes to Path.

Edit:

I reset my Python Paths, and I'm now getting a different error, that's a good thing when it comes to debugging, hopefully.

New Error:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

Upvotes: 2

Views: 3890

Answers (2)

Sherlock
Sherlock

Reputation: 1053

I had the same problem after installing anaconda. When i was trying to use python console in anaconda environment, i was getting this error. Below code fixed my problem.

cd /usr/lib/python2.7
sudo ln -s plat-x86_64-linux-gnu/_sysconfigdata_nd.py .

Upvotes: 3

Heasummn
Heasummn

Reputation: 93

This error was being caused by the Anaconda stack trying to use Python. Removing the Anaconda stack from the Path fixed this error.

I removed the Anaconda stack from the Path by going through the ~/.bashrc file and commenting out the source declaration. You can uncomment this when you want to use Anaconda again.

Upvotes: 2

Related Questions