[英]Python ImportError: No module named requests when requirements are already satisfied
I am using Linux server envirnoment and trying to execute simple python script.我正在使用 Linux 服务器环境并尝试执行简单的 python 脚本。
#!/usr/bin/env python
import os
import requests
After execution i get this error:执行后我得到这个错误:
File "./tele.py", line 4, in <module>
import requests
ImportError: No module named requests
I tried all possible options and also searched earlier threads to resolve the issue but sadly nothing worked so far我尝试了所有可能的选项,还搜索了早期的线程来解决这个问题,但遗憾的是到目前为止没有任何效果
Options I tried:我尝试过的选项:
Install virtual environment and tried pip install request.安装虚拟环境并尝试 pip 安装请求。
pip install requests
Also, tried uninstalling global request library and install only in virtual env.此外,尝试卸载全局请求库并仅在虚拟环境中安装。
It is also getting installed and also giving me message as below:它也正在安装,并给我如下消息:
Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
|################################| 61 kB 31.3 MB/s
Requirement already satisfied: chardet<5,>=3.0.2 in /home/tguser/.local/lib/python3.6/site-packages (from requests) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /home/tguser/.local/lib/python3.6/site-packages (from requests) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /home/tguser/.local/lib/python3.6/site-packages (from requests) (2020.12.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/tguser/.local/lib/python3.6/site-packages (from requests) (1.26.2)
Installing collected packages: requests
Successfully installed requests-2.25.1
Also, tried to add python3 forcefully in my script but that is also not working另外,尝试在我的脚本中强行添加 python3 但这也不起作用
One more option tried:尝试了另一种选择:
import urllib3.requests
pip list is showing the module request, pip 列表显示模块请求,
requests 2.25.1
requests-oauthlib 1.3.0
requests-toolbelt 0.8.0
requests-unixsocket 0.1.5
My python versions are:我的 python 版本是:
Python -V -> Python 2.7.17
Python3 -V -> Python 3.6.9
pip -V -> pip 21.0 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
pip3 -V -> pip 21.0 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
Can anyone help me to resolve the issue?谁能帮我解决这个问题?
-PD -PD
Thanks.谢谢。 The issues was resolved using installation.
问题已通过安装解决。
sudo apt-get install python-requests --upgrade
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.