1

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'
6
  • 3
    check print(requests.__file__) Commented Feb 1, 2017 at 0:00
  • This what I got /usr/local/lib/python2.7/dist-packages/requests/__init__.pyc /usr/local/lib/python2.7/dist-packages/requests/__init__.pyc so ? Commented Feb 1, 2017 at 0:03
  • Did you call your file requests.py? Commented Feb 1, 2017 at 0:04
  • 1
    @user2357112 No, I did mention that in the question. Commented Feb 1, 2017 at 0:06
  • 1
    always put FULL error message in QUESTION - not in ideone. Commented Feb 1, 2017 at 0:09

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.