Abdennacer Lachiheb
Abdennacer Lachiheb

Reputation: 4888

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

I installed the requests package, but when I start to use it, I got this error :

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

This my code :

from bs4 import BeautifulSoup
import requests 

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

I checked some solution to this problem, and most of them saying that either there is a mistake with importing the package, or that a file with the name requests.py exist in the current directory, but it's not the case for me.

it's been a while since I got this error, and I stuck with it.

any idea? thanks.

UPDATE

FULL error message

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'

Upvotes: 1

Views: 4422

Answers (1)

wim
wim

Reputation: 362756

Your file is called parser.py which conflicts with a built-in module name parser.

The error message about requests was a weird and unfortunate coincidence. Just rename your module to something else.

Upvotes: 4

Related Questions