2017-01-31 2 views
0

ich die Anfragen Paket installiert, aber wenn ich es zu benutzen beginnen, ich habe diesen Fehler:Python Attribute: ‚Modul‘ Objekt hat kein Attribut ‚get‘

AttributeError: 'module' object has no attribute 'get' 

Das ist mein Code:

from bs4 import BeautifulSoup 
import requests 

r = requests.get("http://someSite.com/path") 

Ich überprüfte eine Lösung für dieses Problem, und die meisten von ihnen sagen, dass entweder ein Fehler beim Importieren des Pakets oder eine Datei mit dem Namen requests.py im aktuellen Verzeichnis vorhanden ist, aber das ist nicht der Fall für mich .

es ist eine Weile her, seit ich diesen Fehler bekam, und ich blieb dabei.

eine Idee? Vielen Dank.

UPDATE

FULL Fehlermeldung

Traceback (most recent call last): 
    File "parser.py", line 2, in <module> 
    import requests 
    File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 52, in <module> 
    from .packages.urllib3.contrib import pyopenssl 
    File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 47, in <module> 
    from cryptography import x509 
    File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module> 
    from cryptography.x509.base import (
    File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/base.py", line 14, in <module> 
    from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa 
    File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module> 
    from cryptography.hazmat.backends.interfaces import RSABackend 
    File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module> 
    import pkg_resources 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 76, in <module> 
    import parser 
    File "/home/lichiheb/Desktop/parser.py", line 4, in <module> 
    r = requests.get("http://t...content-available-to-author-only...s.com/search-results-jobs/?searchId=1483197031.949&action=search&page=1&view=list") 
AttributeError: 'module' object has no attribute 'get' 
+3

Check 'print (Anfragen .__ Datei __)' – furas

+0

Das, was ich bekam /usr/local/lib/python2.7/dist-packages/requests/__init__.pyc /usr/local/lib/python2.7/dist -Pakete/Anfragen/__ init __. pyc so? –

+0

Hast du deine Datei 'requests.py' aufgerufen? – user2357112

Antwort

4

Ihre Datei parser.py die parser mit einem eingebauten in Modulnamen in Konflikt genannt wird.

Die Fehlermeldung über requests war ein seltsamer und unglücklicher Zufall. Benennen Sie Ihr Modul einfach in etwas anderes um.

+0

Danke, ich bin neu bei Python, so ein dummer Fehler. –

Verwandte Themen