I am trying to run my script but keep getting this error:
JavaScript
x
6
1
File ".checkmypass.py", line 1, in <module>
2
import requests
3
line 3, in <module>
4
response = requests.get(url)
5
AttributeError: partially initialized module 'requests' has no attribute 'get' (most likely due to a circular import)
6
How can I fix it?
Advertisement
Answer
Make sure the name of the file is not the same as the module you are importing – this will make Python think there is a circular dependency.
Also check the URL and the package you are using. “Most likely due to a circular import” refers to a file (module) which has a dependency on something else and is trying to be imported while it’s already been imported. Once it’s correct, you should have something like this:
JavaScript
1
7
1
import requests
2
3
r = requests.get("http://google.com")
4
print(r.status_code)
5
6
# 200
7