相关文章推荐
斯文的杯子  ·  Python+Django 核心介绍 - ...·  3 月前    · 
愤怒的风衣  ·  Python 异步 ASGI ...·  3 月前    · 
奔跑的骆驼  ·  结合使用 Oracle Database ...·  3 月前    · 
踏实的蟠桃  ·  char 初始化 c++-掘金·  2 年前    · 
魁梧的饭盒  ·  Git ...·  3 年前    · 
酒量小的牛排  ·  javascript - 禁用 ...·  3 年前    · 
豪气的墨镜  ·  JS for循环语句的用法·  3 年前    · 

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?

Answers

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:

import requests
r = requests.get("http://google.com")       
print(r.status_code)
# 200
   
  • 浏览量 21
  • 收藏 0
  • 0

所有评论(0)