[英]No module named numpy but requirements are already satisfied (Anaconda)
[英]Python ImportError: No module named requests when requirements are already satisfied
我正在使用 Linux 服務器環境並嘗試執行簡單的 python 腳本。
#!/usr/bin/env python
import os
import requests
執行后我得到這個錯誤:
File "./tele.py", line 4, in <module>
import requests
ImportError: No module named requests
我嘗試了所有可能的選項,還搜索了早期的線程來解決這個問題,但遺憾的是到目前為止沒有任何效果
我嘗試過的選項:
安裝虛擬環境並嘗試 pip 安裝請求。
pip install requests
此外,嘗試卸載全局請求庫並僅在虛擬環境中安裝。
它也正在安裝,並給我如下消息:
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
另外,嘗試在我的腳本中強行添加 python3 但這也不起作用
嘗試了另一種選擇:
import urllib3.requests
pip 列表顯示模塊請求,
requests 2.25.1
requests-oauthlib 1.3.0
requests-toolbelt 0.8.0
requests-unixsocket 0.1.5
我的 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)
誰能幫我解決這個問題?
-PD
謝謝。 問題已通過安裝解決。
sudo apt-get install python-requests --upgrade
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.