22
votes

I am trying to run my script but keep getting this error:

File ".\checkmypass.py", line 1, in <module>
  import requests 
line 3, in <module>
  response = requests.get(url) 
AttributeError: partially initialized module 'requests' has no attribute 'get' (most likely due to a circular import)

How can I fix it?

2

2 Answers

24
votes

Have you checked the name of the file? it should not be as same as the module you are importing (circular). Also check the URL and the package you are using. "Most likely due to a circular import" refers to a file (module) which has got a dependency on something else and is trying to be imported while it's already been imported. Then while checked, you should have something like this:

import requests

r = requests.get("http://google.com")       
print(r.status_code)

# 200
67
votes

I had the same issue. I had a file I created in the same folder called requests.py. So it was actually importing that file and not the actual requests module you install with pip. Then I had another issue with a file I created called logging.py. I renamed both files and the issue was resolved.