如果我做 pip3 安装请求(要求已经满足),
如果我做pip安装请求(要求已经满足),
python3.9 -mpip 安装请求(已满足要求),
好像我已经安装了请求,但我仍然收到“ModuleNotFoundError:没有名为‘requests’的模块”
我的 django 项目中有一个包含此代码的文件
import requests
def client():
credentials = {"username": "admin", "password": "123456789"}
response = requests.post("http://127.0.0.1:8000/api/rest-auth/login/",
data=credentials)
print("Status Code:" , response.status_code)
response_data = response.json()
print(response_data)
if __name__ == "__main__":
client()
答案 0 :(得分:0)
我在此 website
找到了解决方案解决方案:
<块引用>python3 -m pip install --user 请求
然后它安装在 python3 上,但不是 2 或更少,所以它只能在你使用 python3 时工作。
取决于您的默认 Python 版本。我的是 Python 2.7.16
答案 1 :(得分:0)
我不确定,但需要在已安装应用程序部分的 settings.py 文件中设置已安装的包。