无需互联网访问的 pip 安装

问题描述 投票:0回答:1

我想在无法访问互联网的计算机上设置带有模块的Python。

我已经在连接到互联网的具有相同 python 和 pip 版本的计算机上使用 freeze 创建了需求列表,下载了软件包并将其传输到离线计算机。现在我正在尝试安装它们,但遇到了一些困难。它们都是 Windows 机器。请指教,先谢谢了。

PS C:\Users\pulcma\pip> dir


    Directory: C:\Users\pulcma\pip


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         2/1/2024   2:53 PM                pip
-a----         2/1/2024   2:17 PM         158340 bcrypt-4.1.2-cp37-abi3-win_amd64.whl
-a----         2/1/2024   2:17 PM           3439 caugetch-0.0.1-py3-none-any.whl
-a----         2/1/2024   2:17 PM         181358 cffi-1.16.0-cp38-cp38-win_amd64.whl
-a----         2/1/2024   2:17 PM           1713 clipboard-0.0.4.tar.gz
-a----         2/1/2024   2:17 PM          25335 colorama-0.4.6-py2.py3-none-any.whl
-a----         2/1/2024   2:17 PM        2882354 cryptography-42.0.2-cp37-abi3-win_amd64.whl
-a----         2/1/2024   2:17 PM         840896 future-0.18.3.tar.gz
-a----         2/1/2024   2:17 PM           8683 getpass4-0.0.14.1-py3-none-any.whl
-a----         2/1/2024   2:17 PM         219198 netmiko-4.3.0-py3-none-any.whl
-a----         2/1/2024   2:17 PM         416752 ntc_templates-4.2.0-py3-none-any.whl
-a----         2/1/2024   2:17 PM         225900 paramiko-3.4.0-py3-none-any.whl
-a----         2/1/2024   1:27 PM        2109393 pip-23.3.2-py3-none-any.whl
-a----         2/1/2024   2:17 PM         118697 pycparser-2.21-py2.py3-none-any.whl
-a----         2/1/2024   2:17 PM         212141 PyNaCl-1.5.0-cp36-abi3-win_amd64.whl
-a----         2/1/2024   2:17 PM          20920 pyperclip-1.8.2.tar.gz
-a----         2/1/2024   2:17 PM          90585 pyserial-3.5-py2.py3-none-any.whl
-a----         2/1/2024   2:17 PM         157350 PyYAML-6.0.1-cp38-cp38-win_amd64.whl
-a----         2/1/2024   2:54 PM            630 requirements.txt
-a----         2/1/2024   2:17 PM           8653 scp-0.14.5-py2.py3-none-any.whl
-a----         2/1/2024   2:37 PM         575457 setuptools-40.8.0-py2.py3-none-any.whl
-a----         2/1/2024   2:52 PM         576332 setuptools-41.2.0-py2.py3-none-any.whl
-a----         2/1/2024   2:17 PM          11053 six-1.16.0-py2.py3-none-any.whl
-a----         2/1/2024   2:17 PM          44664 textfsm-1.1.3-py2.py3-none-any.whl


PS C:\Users\pulcma\pip> pip install -r requirements.txt --find-links=C:\Users\pulcma\pip --no-index
Looking in links: c:\Users\pulcma\pip
Processing c:\users\pulcma\pip\bcrypt-4.1.2-cp37-abi3-win_amd64.whl (from -r requirements.txt (line 1))
Processing c:\users\pulcma\pip\caugetch-0.0.1-py3-none-any.whl (from -r requirements.txt (line 2))
Processing c:\users\pulcma\pip\cffi-1.16.0-cp38-cp38-win_amd64.whl (from -r requirements.txt (line 3))
Processing c:\users\pulcma\pip\colorama-0.4.6-py2.py3-none-any.whl (from -r requirements.txt (line 4))
Processing c:\users\pulcma\pip\cryptography-42.0.2-cp37-abi3-win_amd64.whl (from -r requirements.txt (line 5))
Processing c:\users\pulcma\pip\netmiko-4.3.0-py3-none-any.whl (from -r requirements.txt (line 6))
Processing c:\users\pulcma\pip\ntc_templates-4.2.0-py3-none-any.whl (from -r requirements.txt (line 7))
Processing c:\users\pulcma\pip\paramiko-3.4.0-py3-none-any.whl (from -r requirements.txt (line 8))
Processing c:\users\pulcma\pip\pycparser-2.21-py2.py3-none-any.whl (from -r requirements.txt (line 9))
Processing c:\users\pulcma\pip\pynacl-1.5.0-cp36-abi3-win_amd64.whl (from -r requirements.txt (line 10))
Processing c:\users\pulcma\pip\pyserial-3.5-py2.py3-none-any.whl (from -r requirements.txt (line 11))
Processing c:\users\pulcma\pip\pyyaml-6.0.1-cp38-cp38-win_amd64.whl (from -r requirements.txt (line 12))
Processing c:\users\pulcma\pip\scp-0.14.5-py2.py3-none-any.whl (from -r requirements.txt (line 13))
Processing c:\users\pulcma\pip\six-1.16.0-py2.py3-none-any.whl (from -r requirements.txt (line 14))
Processing c:\users\pulcma\pip\textfsm-1.1.3-py2.py3-none-any.whl (from -r requirements.txt (line 15))
Processing c:\users\pulcma\pip\clipboard-0.0.4.tar.gz (from -r requirements.txt (line 16))
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [4 lines of output]
      Looking in links: c:\Users\pulcma\pip
      Processing c:\users\pulcma\pip\setuptools-41.2.0-py2.py3-none-any.whl
      ERROR: Could not find a version that satisfies the requirement wheel (from versions: none)
      ERROR: No matching distribution found for wheel
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
PS C:\Users\pulcma\pip>
python offline
1个回答
0
投票

您必须在您的在线电脑上下载轮子包

pip download wheel

然后将文件传输到离线电脑上并安装

pip install yourwheelpackagename.whl

那么安装一定可以工作

pip install -r requirements.txt --find-links=C:\Users\pulcma\pip --no-index
© www.soinside.com 2019 - 2024. All rights reserved.