AttributeError: 'module' object has no attribute 'DrtParser' - python

I already checked all similar thread, but no help.
>>> from nltk import load_parser
>>> parser = load_parser('grammars/book_grammars/drt.fcfg', logic_parser=nltk.sem.drt.DrtParser())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'DrtParser'
code is given at : http://www.nltk.org/book/ch10.html just above 5.2
>>> print nltk.sem.drt
<module 'nltk.sem.drt' from '/usr/local/lib/python2.7/dist-packages/nltk/sem/drt.pyc'>
what can be the issue?
/nltk/sem has drt.py and drt.pyc files

Related

Are there any objects that do not contain the __name__ attribute? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Are there any objects that do not contain the __name__ attribute? Does the object data always comprise the object name?
Are there any objects that do not contain the __name__ attribute?
Of course:
>>> (4).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__name__'
>>> (3.14).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'float' object has no attribute '__name__'
>>> (6+8j).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'complex' object has no attribute '__name__'
>>> 'hello'.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute '__name__'
>>> [].__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute '__name__'
>>> ....__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'ellipsis' object has no attribute '__name__'
And on and on it goes...

OpenCV's extra module cv2.face is not known

Traceback (most recent call last):
File "C:\Users\asus\Google Drive\Miroir intelligent\code\Reconnaissance faciale\PyFaceRec-master\SimpleFaceRecognition\simple_face_recognition.py", line 58, in
recognizer = cv2.face.createFisherFaceRecognizer()
AttributeError: module 'cv2.cv2' has no attribute 'face'
collector = cv2.face.StandardCollector_create()

fuzzy installed successfully but fuzzy.Soundex(4) has problems in python

Code:
>>> import fuzzy
>>> soundex = fuzzy.Soundex(4)
Error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
soundex = fuzzy.Soundex(4)
AttributeError: 'module' object has no attribute 'Soundex'
I really don't know why, please help if you know about it!

Getting TypeError while importing urllib

When I write the following line of code
import urllib
I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 26, in <module>
import socket
File "socket.py", line 2, in <module>
s = socket.socket()
TypeError: 'module' object is not callable
After going through various questions on SO I tried these:
from urllib import urlopen
(Same error as above)
>>> urllib
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>> urllib.urlopen()
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
Please help. I get a similar error when I try to import urllib2, urllib3, requests.
You named your file socket.py, hiding the standard library socket module. Name it something else.

"argument 1 has unexpected type 'str'"

I'm trying to use PyKDE, PyKDE.kdecore.KStandardDirs to be precise. This method is called with two strings according to the documentation and according to the PyQt4 documentation, I can use standard Python strs instead of QString.
This doesn't work:
>> KStandardDirs.locate()("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): not enough arguments
>>> KStandardDirs.locate("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): argument 1 has unexpected type 'str'
I can't use QString either because it doesn't seem to exist:
>>> from PyQt4.QtCore import QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name QString
>>> from PyQt4.QtCore import *
>>> QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'QString' is not defined
What am I doing wrong?
I suspect that PyKDE is not yet Python 3 ready, at least as far as that error message is concerned; try passing in a bytestring instead:
KStandardDirs.locate(b"socket", "foo")

Categories