2024年1月12日 星期五

[python] pip install offline without network 離線狀態安裝 package

怎麼在離線的狀態安裝 python package呢?

可以在有網路連線的服務器上先 pip install

pip install google-cloud-bigquery

pip freeze >  requirements.txt 

可以挑選需要的package在 requirements.txt  
把package download到資料夾

pip download -r requirements.txt -d libraries 

之後就可以透過 --no-index --find-links libraries 離線安裝該package

pip install -r requirements.txt --no-index --find-links libraries


由於pip 都會去確認 index 所以可以加上 --no-index
  --no-index        Ignore package index (only looking at --find-links
                              URLs instead).

```
pip install slack-bolt
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/slack-bolt/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/slack-bolt/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/slack-bolt/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/slack-bolt/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/slack-bolt/
ERROR: Could not find a version that satisfies the requirement slack-bolt (from versions: none)
ERROR: No matching distribution found for slack-bolt
```

沒有留言:

張貼留言