简体   繁体   English

Python ImportError:当要求已经满足时,没有名为请求的模块

[英]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.

相关问题 没有名为 numpy 的模块,但已满足要求 (Anaconda) - No module named numpy but requirements are already satisfied (Anaconda) 需求已经满足但是ImportError:没有名为“pkg”的模块 - Requirement already satisfied but ImportError: No module named “pkg” ImportError:没有名为请求的模块,但模块已存在 - ImportError: No module named requests but module already exists Python-ImportError:尽管pip表示“要求已满足”,但没有名为“ pymongo”的模块[Windows] - Python - ImportError: No module named 'pymongo' despite pip says “requirement already satisfied” [Windows] ImportError:没有名为请求的模块-Python - ImportError: No module named requests - Python Python-ImportError:没有名为“ requests”的模块 - Python - ImportError: No module named 'requests' ImportError: No module named requests: 但它已经安装 - ImportError: No module named requests: But it is installed already 使用 Python3 的 Jupyter 中没有名为“请求”的模块,但 Python3 的“要求已经满足” - No module named 'requests' in Jupyter with Python3, but "Requirement already satisfied" for Python3 Python - 导入请求 ImportError: No module named requests - Python - import requests ImportError: No module named requests ImportError: No module named requests 试图安装请求模块,但它已经被其他 python 版本填充 - ImportError: No module named requests tried to install requests modeule but it's already fullfilled by other python version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM