[Python] ImportError: No module named requests

Khắc phục lỗi ImportError: No module named requests khi chạy ứng dụng Python

Nếu các bạn gặp lỗi khi chạy ứng dụng Python

File "test.py", line 1, in <module>
    import requests
ImportError: No module named requests

Các bạn có thể khách phục bằng cách cài đặt thêm module request

Lệnh cài đặt module requests

pip install requests

Màn hình output khi cài đặt

C:\Project>pip install requests
Collecting requests
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 3.8 MB/s
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 3.3 MB/s
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 3.8 MB/s
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 3.3 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
     |████████████████████████████████| 153 kB 3.3 MB/s
Installing collected packages: chardet, idna, certifi, urllib3, requests
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.4
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\users\administrator\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.

Chúc các bạn thành công.

Bình luận