Reputation:
When I try the "python" or "python3" command to run the interpreter, this is the error am getting.
[sidgupta234@sidgupta234-Lenovo-G580 Downloads]$ python
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'
Output to which python
[sidgupta234@sidgupta234-Lenovo-G580 Downloads]$ which python
/usr/bin/python
Output to python -V
[sidgupta234@sidgupta234-Lenovo-G580 Downloads]$ python -V
Python 3.5.2 :: Continuum Analytics, Inc.
Could you tell me the reason of this error and how can I remove it?
I found this link while looking for the solution, but it didnt make any difference.
Upvotes: 1
Views: 1886
Reputation: 10556
That is an strange situation you have gotten yourself into, and if Continuum had any part of it (where I'm an engineer) we'd like to understand what we did that led to it so we can avoid it in the future.
Where did you try installing Anaconda? Did you set any environment variables?
The "easiest-to-resolve" cause of this problem is that you have set some environment variables that are mixing system Python libraries and Anaconda Python libraries. You should look at the output of:
env | grep -i anaconda
and see if anything comes up that specifies a path to Anaconda. The only one that should appear is an entry in PATH
. If there are any LD_LIBRARY_PATH
, PYTHONPATH
, PYTHONHOME
or similar environment variables that point to Anaconda then that is going to be a problem.
The only other thing I can think of is that you specified /usr
as the install path for Anaconda. If that is the case you are probably in for a world of pain: you have just replaced your system Python with Anaconda. You should investigate how to force-reinstall whichever Python package comes with your *nix distribution, but even that might be tricky: tools such as yum
are written in Python and will need a working system Python interpreter to work. But RPM is binary (if you're on a RedHat or derivative distro), so maybe you can wget
or curl
the necessary system Python packages and force-install them to try and fix things.
Let us know if that is enough information for you to fix things or at least identify the source of the problem a little better.
Upvotes: 0
Reputation: 196
I guess configuring_apache_django_anaconda is relevant, if you look at the troubleshooting section.
This means that apache is using Python 2 instead of Python 3 to run a program that is designed for Python 3 only, and fails because Python 2 does not have the _sysconfigdata_m module. The solution is to add the following file to your apache envvar file (/etc/apache2/envvar): export PATH=/opt/anaconda3/bin:$PATH
So maybe check which version of python anaconda is running?
Also these two might be related:Linux - Weird Python Output
I would suggest you print your PATH variable to see if you have several python3 entries in there, and try to specify explicity which one to run.
Upvotes: 1