在没有互联网连接的情况下安装 python 包
Install python package without internet connection
我需要在无法访问互联网的机器上使用 pip 安装 python 包。为此,我尝试从以下 link 下载这些软件包:https://www.lfd.uci.edu/~gohlke/pythonlibs/
我以为 whl 文件是完整的包,但是当我尝试使用 pip 安装时,出现以下错误
pip 安装 .\pyproj-3.2.1-cp310-cp310-win_amd64.whl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewC
onnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000F76ABA6EC0>: Failed to establish a new
connection: [WinError 10061] No connection could be made because the target machine actively refused it')':
ERROR: Could not find a version that satisfies the requirement certifi (from pyproj) (from versions: none)
ERROR: No matching distribution found for certifi
我需要安装的包是:
- Numpy
- GDAL
- PYPROJ
- 菲奥娜
- 身材匀称
- GEOPANDAS
我也尝试在我的本地机器上通过互联网连接进行 pip 下载,但是当我尝试使用生成的 whl 时,我遇到了同样的问题
我应该如何继续安装这些软件包?
像这样
pip install --no-index --find-links=<lolcal-folder> <package-name>
例如
pip install --no-index --find-link=/tmp/python-wheels exchangelib
我终于找到了解决办法。我不知道这是否是最好的方法,但它确实有效。
- 在一台联网的机器上,我在虚拟环境中安装了所有需要的包。
- 我用
pip freeze > requirements.txt
创建了一个 requirement.txt。
- 我用
pip download -r requirement.txt
下载了包
- 我复制到另一台机器上了。
- 我用文件名 (
ls > requirements.txt
) 创建了一个新的 requirements.txt
。
- 我用
pip install -r requirements.txt
安装了软件包。
我需要在无法访问互联网的机器上使用 pip 安装 python 包。为此,我尝试从以下 link 下载这些软件包:https://www.lfd.uci.edu/~gohlke/pythonlibs/ 我以为 whl 文件是完整的包,但是当我尝试使用 pip 安装时,出现以下错误
pip 安装 .\pyproj-3.2.1-cp310-cp310-win_amd64.whl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewC
onnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000F76ABA6EC0>: Failed to establish a new
connection: [WinError 10061] No connection could be made because the target machine actively refused it')':
ERROR: Could not find a version that satisfies the requirement certifi (from pyproj) (from versions: none)
ERROR: No matching distribution found for certifi
我需要安装的包是:
- Numpy
- GDAL
- PYPROJ
- 菲奥娜
- 身材匀称
- GEOPANDAS
我也尝试在我的本地机器上通过互联网连接进行 pip 下载,但是当我尝试使用生成的 whl 时,我遇到了同样的问题
我应该如何继续安装这些软件包?
像这样
pip install --no-index --find-links=<lolcal-folder> <package-name>
例如
pip install --no-index --find-link=/tmp/python-wheels exchangelib
我终于找到了解决办法。我不知道这是否是最好的方法,但它确实有效。
- 在一台联网的机器上,我在虚拟环境中安装了所有需要的包。
- 我用
pip freeze > requirements.txt
创建了一个 requirement.txt。 - 我用
pip download -r requirement.txt
下载了包 - 我复制到另一台机器上了。
- 我用文件名 (
ls > requirements.txt
) 创建了一个新的requirements.txt
。 - 我用
pip install -r requirements.txt
安装了软件包。