could you please explain me the error below, and give me a workaround?
Thanks in advance!
Python 2.4.3 (#1, Apr 14 2011, 20:41:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.sax import make_parser
>>> p = make_parser()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.4/site-packages/_xmlplus/sax/sax2exts.py", line 37, in make_parser
return XMLParserFactory.make_parser(parser_list)
File "/usr/lib64/python2.4/site-packages/_xmlplus/sax/saxexts.py", line 75, in make_parser
sys.modules[parser_name].create_parser = _create_parser
KeyError: 'xml.sax.drivers2.drv_pyexpat'
>>>
Problem seems to be with your python version and python library.
Have a look here
Related
How does the following python session make sense?
(ctlearn) jsevillamol#jsevillamol-N551JK:~/Documentos/ctlearn_keras$ python
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:39:56)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow.python.keras.models import Model
>>> import tensorflow.python.keras as K
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'python'
I can import tensorflow.python.keras.models, but not import tensorflow.python.keras.
What. I don't even.
mac 10.11osx,and mysql5.5 python 2.7(system) mysqldb1.2.5,but when i do "import MySQLdb",it wrong----------
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.11-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.11-intel.egg/_mysql.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.11-intel.egg/_mysql.so: mach-o, but wrong architecture
could someone tell me why?
Isn't log a built in package in python?
# /usr/bin/python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import log as logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named log
>>>
Do I need to install log with pip ?
logging is a built-in package, not log:
import logging as log
Using Python 2.7 on Ubuntu 12.10 64Bit gives me the following trouble:
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.c_bool()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'c_bool'
>>>
How can I fix this problem?
Do you have a file called "ctypes.py" in the directory where you are working? If so, move it or (preferably) rename it.
[root#proxy-001 scripts]# python
Python 2.6.6 (r266:84292, Dec 7 2011, 20:48:22)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> from MySQLdb import cursors
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 16, in <module>
insert_values= re.compile(restr)
AttributeError: 'module' object has no attribute 'compile'
any ideas?
Same error:
[root#proxy-001 scripts]# python
Python 2.6.6 (r266:84292, Dec 7 2011, 20:48:22)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> import MySQLdb
>>> import MySQLdb.cursors
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 16, in <module>
insert_values= re.compile(restr)
AttributeError: 'module' object has no attribute 'compile'
edited: /usr/lib64/python2.6/site-packages/MySQLdb/cursors.py
added:
print re
print dir(re)
insert_values= re.compile(restr)
[root#proxy-001 scripts]# python
Python 2.6.6 (r266:84292, Dec 7 2011, 20:48:22)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> import MySQLdb
>>> import MySQLdb.cursors
<module 're' from 're.pyc'>
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'main', 'modify_url', 'sys']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 18, in <module>
insert_values= re.compile(restr)
AttributeError: 'module' object has no attribute 'compile'
>>>
That's strange. Do you have a module named "re.py" somewhere in your Python path which is shadowing the "real" re module?
UPDATE: Okay, based on your edit, I'm now certain that you have an re.py module which is shadowing the real one, and if I'm reading the path correctly, it's in the very directory you're calling the program from! Did you write an re.py module which has one "modify_url" function?
Anyway, find that re.py -- it's probably in your scripts directory -- and rename it to something else.