此答案Internet:
如果要安装Python Libs及其依赖项离线,请在具有相同OS,网络连接的机器上遵循以下步骤,并安装了Python:
-
创建一个 insuert.txt
具有相似的文件内容(注意 - 这些是您要下载的库):
烧瓶== 0.12
请求> = 2.7.0
Scikit-learn == 0.19.1
numpy == 1.14.3
pandas == 0.22.0
创建需求文件的一个选项是使用 pip冻结>需求.txt
。这将列出您环境中的所有库。然后,您可以进入 unignts.txt
并删除不需要的。
-
执行命令 mkdir Wheelhouse&& pip下载-r需求.txt -d惠室
要下载libs及其依赖项 heelhouse
-
复制要求。 >
存档驾驶室 wheelhouse.tar.gz
带有 tar -zcf heelhouse.tar.tar.gz wheelhouse
< < < /p>
然后上传 wheelhouse.tar.gz
到您的目标机器:
-
执行 tar -zxf heelhouse.tar.gz
提取文件
执行 pip install -r heelhouse/insuert.txt -no -index -no -index -find -links wheelhouse
安装LIB及其依赖项
这正是我在做的,除了我的unignts.txt,目前,仅是:
笔记本== 7.0.0a4
是jupyter笔记本。
但奇怪的是,我遇到了错误:
ERROR: Could not find a version that satisfies the requirement pyzmq>=17 (from jupyter-server) (from versions: none)
ERROR: No matching distribution found for pyzmq>=17
我弄清楚了如何在此错误上取得进展:
。似乎I 可以将这些软件包显式地添加到 unigess.txt
中,但这似乎远不及最佳,尤其是如果有很多软件包要添加。我是否可以将某些内容添加到车轮构建命令中以获取所有这些依赖项而无需手动进行操作?
This answer (and the one above it) explains a way to install pip requirements on an offline machine by first involving a machine with internet:
If you want install python libs and their dependencies offline, finish following these steps on a machine with the same os, network connected, and python installed:
-
Create a requirements.txt
file with similar content (Note - these are the libraries you wish to download):
Flask==0.12
requests>=2.7.0
scikit-learn==0.19.1
numpy==1.14.3
pandas==0.22.0
One option for creating the requirements file is to use pip freeze > requirements.txt
. This will list all libraries in your environment. Then you can go in to requirements.txt
and remove un-needed ones.
-
Execute command mkdir wheelhouse && pip download -r requirements.txt -d wheelhouse
to download libs and their dependencies to directory wheelhouse
-
Copy requirements.txt into wheelhouse
directory
-
Archive wheelhouse into wheelhouse.tar.gz
with tar -zcf wheelhouse.tar.gz wheelhouse
Then upload wheelhouse.tar.gz
to your target machine:
-
Execute tar -zxf wheelhouse.tar.gz
to extract the files
-
Execute pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse
to install the libs and their dependencies
This is exactly what I'm doing, except my requirements.txt, for now, is just:
notebook==7.0.0a4
which is Jupyter Notebook.
But oddly, I'm getting the error:
ERROR: Could not find a version that satisfies the requirement pyzmq>=17 (from jupyter-server) (from versions: none)
ERROR: No matching distribution found for pyzmq>=17
I figured out how to make progress on this error:
- Adding
pyzmq==17
to my requirements.txt
But then the same error appears for a similar package, so it seems like I could just keep explicitly adding these packages to requirements.txt
but that seems a bit less than optimal, especially if there are a lot of packages to add. Is there something I could add to the wheel building command to get all these dependencies included without doing so manually?
发布评论
评论(1)
听起来您遵循了步骤1 ,一个并手动创建了
sumplliant.txt
用内容笔记本== 7.0.0a4
,但错过了所说的部分:如果我手动安装笔记本,请在“互联网连接”的计算机上(可能最好使用新的虚拟env来防止其他项目的dep泄漏),然后使用:
然后 用:
这给我一个
unignts.txt
包含的文件:我认为这是制作需求文件的方法,然后将其输入步骤2 ,这意味着所有所需的dep都进入驾驶室以导出到该驾驶室,以“导出到”离线计算机”。
Sounds like you've followed step 1, one and manually created the
requirements.txt
with the contentsnotebook==7.0.0a4
, but missed the part where it say's:If I manually install notebook, on the "internet connected" computer (probably best use a fresh virtual env to prevent other project's deps leaking in) with:
Then export the requirements with:
This gives me a
requirements.txt
file containing:I think this is how to make the requirements file, which you then feed into step 2 meaning all the required deps go into the wheelhouse for export to the "offline computer".