已經安裝 requests module, 但是執行後仍然出現 No module named requests
C:\Users\User\Downloads>pip install requests
Requirement already satisfied: requests in c:\python37\lib\site-packages (2.26.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\python37\lib\site-packages (from requests) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in c:\python37\lib\site-packages (from requests) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\python37\lib\site-packages (from requests) (1.26.7)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\python37\lib\site-packages (from requests) (2.0.6)
C:\Users\User\Downloads>python Untitled-1.py
Traceback (most recent call last):
File "Untitled-1.py", line 4, in <module>
import requests
ImportError: No module named requests
C:\Users\User\Downloads>python --version
Python 2.7.15
發現python version 不正確. requests module 應該安裝到python37 檢查環境變數, 移除C:\Python27\ 之後可以正常執行
關閉命令提示視窗, 重新打開後再次檢查version, Untitled-1.py 可以正常執行
C:\Users\User\Downloads>python --version
Python 3.7.0
|