I get this error many times whenever I try to run a python module.. for example i tried running pyspark from spark bin folder and getting the error shown below..
soundarya#soundarya:~/spark/spark-1.5.1-bin-hadoop2.6/bin$ ./pyspark
Traceback (most recent call last):
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 236, in getuserbase
from sysconfig import get_config_var
ImportError: No module named sysconfig
soundarya#soundarya:~$ whereis python2.7
python2: /usr/bin/python2.6 /usr/bin/python2.7 /usr/bin/python2.6-config /usr/bin/python2 /usr/bin/python2.7-config /usr/lib/python2.6 /usr/lib/python2.7 /etc/python2.6 /etc/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/include/python2.7 /opt/splunk.old/bin/python2.7 /opt/splunk.old/bin/python2 /opt/splunk/bin/python2.7 /opt/splunk/bin/python2 /usr/share/man/man1/python2.1.gz
can anyone help to fix this issue? thank you so much in advance.
Related
I'm trying to open my jupyter notebook with Conda Python3.6. When I try to open it, I'm getting this error
VikMacBook-Pro:~ vik$ /anaconda3/bin/jupyter_mac.command ; exit;
Failed to import the site module
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site.py", line 541, in <module>
main()
File "/anaconda3/lib/python3.6/site.py", line 522, in main
known_paths = addusersitepackages(known_paths)
File "/anaconda3/lib/python3.6/site.py", line 282, in
addusersitepackages
user_site = getusersitepackages()
File "/anaconda3/lib/python3.6/site.py", line 258, in
getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/anaconda3/lib/python3.6/site.py", line 248, in getuserbase
USER_BASE = get_config_var('userbase')
File "/anaconda3/lib/python3.6/sysconfig.py", line 608, in
get_config_var
return get_config_vars().get(name)
File "/anaconda3/lib/python3.6/sysconfig.py", line 587, in
get_config_vars
import _osx_support
File "/anaconda3/lib/python3.6/_osx_support.py", line 4, in <module>
import re
File "/anaconda3/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
And I have attempted to solve by following this endorsed answer, using command
pip uninstall enum34
However, I'm still getting the following error after running this command
Vik-MacBook-Pro:~ vik$ pip uninstall enum34
Skipping enum34 as it is not installed.
I do not have my own code file named enum.py
try using "pip3 uninstall enum34" it worked for me
I'm building Hello World using cython embed. Using docker python-3.5.3 image (Debian Jessie, with libpython3.5-dev additionaly installed)
hello.py:
print('hello world')
building:
cython --embed -o hello.c hello.py
gcc -I /usr/include/python3.5 -o hello hello.c -lpython3.5m
After trying to run i get ImportError:
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'
I suggest that something is wrong with PATH or PYTHONPATH, but launching binary file with directly set environment fails with same error.
I used
find / -name '_sysconfigdata_m.py'
/usr/lib/python3.5/plat-x86_64-linux-gnu/_sysconfigdata_m.py
And then
cp /usr/lib/python3.5/plat-x86_64-linux-gnu/_sysconfigdata_m.py /usr/lib/python3.5 Everything worked fine.
But I still wonder - why _sysconfigdata_m is not placed in /usr/lib/python3.5 by default.
When ever i mistype or do a error into the console the following message come up:
Traceback (most recent call last):
File "/usr/lib/python3.3/site.py", line 629, in <module>
main()
File "/usr/lib/python3.3/site.py", line 614, 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 610, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python3.3/sysconfig.py", line 560, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python3.3/sysconfig.py", line 432, 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 have both Python 2.7 and 3.3 install with Anaconda. I wonder if this is normal or it was a conflict between python 2.7 and 3.3
Assuming you are using ubuntu, here is the relevant bug report https://bugs.launchpad.net/ubuntu/+source/python3.3/+bug/1192890
You need to patch your /etc/bash.bashrc. See comment #6 for details
Actually, it's possible you have another python3 in your PATH before /usr/bin (most probably in /usr/local/bin) in your system, one which lacks the ubuntu-provided libraries (used by /usr/bin/python3). That happens with hashbangs using #!env python3 and the PATH environment variable.
If this is the case, then temporarily make unavailable (eg renaming them) all such non-/usr/bin/python3* executables, do your system administration stuff and then make them again available.
I installed the Winpython distribution on my copy of Windows 7. Launching iPython consoles and other items from the distribution from within the folder it copied to works fine.
I'd like to use the f2py module from numpy to be able to call Fortran subroutines from Python. My understanding is that f2py must be called from the command line, but the system does not seem to find f2py, returning ImportError: no module named site when I call it either with or without flags. This same error is returned when I try to run python itself from the command line.
When I manually navigate to the Winpython directory (e.g. C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5) and call f2py -c --help-fcompiler to see if f2py is found there, I receive the following error
Traceback (most recent call last):
File ".\lib\site.py", line 538, in main
main()
File ".\lib\site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File ".\lib\site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File ".\lib\site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File ".\lib\site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 516, in get_config_var
return get_config_vars().get(name)
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 449, in get_config_vars
import re
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\re.py", line 1
05, in <module>
import sre_compile
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_parse.py"
", line 14, in <module>
import sre_parse
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_constants.py",
line 17, in <module>
from sre_constants import *
File "C:\Users\konings\WinPython-32bit-2.7.5.3\pyt
py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Could somebody explain to me what this error means and/or how to use f2py with Winpython? Thanks!
You can set your environment variable PYTHONPATH pointing to the folder where these modules are. This should solve the ImportErrors.
I'm trying to install GDAL-1.9.0 under Ubuntu 10.04 via buildout and unfortunately get a very strange error.
python setup.py build
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "setup.py", line 75, in <module>
from distutils.command.build_ext import build_ext
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 13, in <module>
from site import USER_BASE, USER_SITE
File "/home/student/geoserv_new/geoportal2/trunk/parts/buildout/site.py", line 601, in <module>
main()
File "/home/student/geoserv_new/geoportal2/trunk/parts/buildout/site.py", line 583, in main
known_paths = addusersitepackages(known_paths)
File "/home/student/geoserv_new/geoportal2/trunk/parts/buildout/site.py", line 271, in addusersitepackages
user_site = getusersitepackages()
File "/home/student/geoserv_new/geoportal2/trunk/parts/buildout/site.py", line 246, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/home/student/geoserv_new/geoportal2/trunk/parts/buildout/site.py", line 235, in getuserbase
from sysconfig import get_config_var
ImportError: No module named sysconfig
make[2]: *** [build] Error 1
make[2]: Leaving directory `/tmp/tmpY7oYvSbuildout-gdal/gdal-1.9.0/swig/python'
make[1]: *** [build] Error 2
make[1]: Leaving directory `/tmp/tmpY7oYvSbuildout-gdal/gdal-1.9.0/swig'
make: *** [swig-modules] Error 2
gdal: cmmi failed: /tmp/tmpY7oYvSbuildout-gdal
While:
Installing gdal.
An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.buildout-1.5.2-py2.7.egg/zc/buildout/buildout.py", line 1805, in main
getattr(buildout, command)(args)
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.buildout-1.5.2-py2.7.egg/zc/buildout/buildout.py", line 584, in install
installed_files = self[part]._call(recipe.install)
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.buildout-1.5.2-py2.7.egg/zc/buildout/buildout.py", line 1297, in _call
return f()
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.recipe.cmmi-1.3.5-py2.7.egg/zc/recipe/cmmi/__init__.py", line 113, in install
self.build()
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.recipe.cmmi-1.3.5-py2.7.egg/zc/recipe/cmmi/__init__.py", line 196, in build
self.cmmi(dest)
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.recipe.cmmi-1.3.5-py2.7.egg/zc/recipe/cmmi/__init__.py", line 222, in cmmi
system("make")
File "/home/student/geoserv_new/geoportal2/trunk/eggs/zc.recipe.cmmi-1.3.5-py2.7.egg/zc/recipe/cmmi/__init__.py", line 34, in system
raise SystemError("Failed", c)
SystemError: ('Failed', 'make')
Here is my buildout.cfg part of gdal:
[gdal]
recipe = zc.recipe.cmmi
url = http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
extra_options =
--with-python
--with-geos=${geos:location}/bin/geos-config
Even more strange that when I'm going to python2.7 shell and try import sysconfig. Everything is working fine. Any suggestion about this?
Thanks,
Sergey
You mention that you tested it in the 'python2.7' shell.
This:
File "/usr/lib/python2.6/distutils/command/build_ext.py",
Implies that buildout is running in python 2.6.
Is sysconfig available in your python2.6 environment, or are you running buildout under the wrong version?