首頁 > 軟體

離線安裝python的requests庫方法

2022-02-09 19:01:39

前言

 本文詳細記錄了在win7中離線安裝python requests的過程,包括安裝requests所需依賴包。

環境:win7、python3.8.9(win7中可安裝的最新python版本)、無法連線網際網路

1、下載安裝包

1.1 檢查requests模組所需依賴包

在可以上網且已經安裝python的機器上檢查requests模組需要哪些依賴包,如果這些依賴包未安裝,直接安裝requests也不能使用。

使用命令:

pip show requests

 發現需要chardet,idna,urllib3,certifi

檢查這幾個包是否已安裝,如果未安裝,則也需要手工安裝。

1.2 下載requests所需依賴包

在網站 https://www.lfd.uci.edu/~gohlke/pythonlibs 上找到相應的程式,下載並傳輸至目標機器。

1.3 下載requests包

從github下載requests原始碼包並傳輸至目標機器。

https://github.com/kennethreitz/requests

將requests-master.zip解壓到python的安裝目錄中

2、安裝

2.1 安裝requests所需依賴包

安裝命令為

 pip install xx.whl

下圖中最後一個是正常安裝成功,前面三個有報錯資訊,目前暫時忽略,因為經過驗證沒有影響requests安裝。

D:python-lib>pip install urllib3-1.26.8-py2.py3-none-any.whl
Processing d:python-liburllib3-1.26.8-py2.py3-none-any.whl
Installing collected packages: urllib3
ERROR: After October 2020 you may experience errors when installing or updating packages. 
This is because pip will change the way that it resolves dependency conflicts.
 
We recommend you use --use-feature=2020-resolver to test your packages with the
new resolver before it becomes the default.
 
requests 2.25.1 requires certifi>=2017.4.17, which is not installed.
requests 2.25.1 requires chardet<5,>=3.0.2, which is not installed.
requests 2.25.1 requires idna<3,>=2.5, which is not installed.
Successfully installed urllib3-1.26.8
 
D:python-lib>pip install chardet-4.0.0-py3-none-any.whl
Processing d:python-libchardet-4.0.0-py3-none-any.whl
Installing collected packages: chardet
ERROR: After October 2020 you may experience errors when installing or updating
packages. This is because pip will change the way that it resolves dependency co
nflicts.
 
We recommend you use --use-feature=2020-resolver to test your packages with the
new resolver before it becomes the default.
 
requests 2.25.1 requires certifi>=2017.4.17, which is not installed.
requests 2.25.1 requires idna<3,>=2.5, which is not installed.
Successfully installed chardet-4.0.0
 
D:python-lib>pip install certifi-2019.11.28-py2.py3-none-any.whl
Processing d:python-libcertifi-2019.11.28-py2.py3-none-any.whl
Installing collected packages: certifi
ERROR: After October 2020 you may experience errors when installing or updating
packages. This is because pip will change the way that it resolves dependency co
nflicts.
 
We recommend you use --use-feature=2020-resolver to test your packages with the
new resolver before it becomes the default.
 
requests 2.25.1 requires idna<3,>=2.5, which is not installed.
Successfully installed certifi-2019.11.28
 
D:python-lib>pip install idna-2.8-py2.py3-none-any.whl
Processing d:python-libidna-2.8-py2.py3-none-any.whl
Installing collected packages: idna
Successfully installed idna-2.8
 
D:python-lib>

2.2 安裝requests

在解壓好的equests-master目錄下開啟cmd(或者cmd中切換目錄至該路徑)

 輸入命令開始安裝

python setup.py install

3、檢查是否安裝成功

在python中使用import requests檢視

總結

到此這篇關於離線安裝python的requests庫方法的文章就介紹到這了,更多相關python requests庫離線安裝內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com