2021年12月8日 星期三

Python 學習筆記 : 離線安裝 netmiko 相依套件 ntc_templates 的問題

昨天用 paramiko 連線公司主機出現錯誤, 今天嘗試安裝 netmiko 來試試看是否 OK. 首先在筆電在線安裝 netmiko 沒問題 (目的是觀察它有哪些相依套件) :

C:\Users\User>pip install netmiko    
Collecting netmiko
  Downloading netmiko-3.4.0-py3-none-any.whl (178 kB)
Requirement already satisfied: pyserial in c:\python37\lib\site-packages (from netmiko) (3.4)
Collecting ntc-templates
  Downloading ntc_templates-3.0.0-py3-none-any.whl (303 kB)
Collecting scp>=0.13.2
  Downloading scp-0.14.1-py2.py3-none-any.whl (8.4 kB)
Requirement already satisfied: setuptools>=38.4.0 in c:\python37\lib\site-packages (from netmiko) (51.0.0)
Collecting paramiko>=2.6.0
  Downloading paramiko-2.8.1-py2.py3-none-any.whl (206 kB)
Collecting tenacity
  Downloading tenacity-8.0.1-py3-none-any.whl (24 kB)
Collecting bcrypt>=3.1.3
  Downloading bcrypt-3.2.0-cp36-abi3-win_amd64.whl (28 kB)
Collecting cryptography>=2.5
  Downloading cryptography-36.0.0-cp36-abi3-win_amd64.whl (2.2 MB)
Collecting pynacl>=1.0.1
  Downloading PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl (206 kB)
Collecting textfsm<2.0.0,>=1.1.0
  Downloading textfsm-1.1.2-py2.py3-none-any.whl (44 kB)
Collecting cffi>=1.1
  Downloading cffi-1.15.0-cp37-cp37m-win_amd64.whl (179 kB)
Requirement already satisfied: six>=1.4.1 in c:\python37\lib\site-packages (from bcrypt>=3.1.3->paramiko>=2.6.0->netmiko) (1.12.0)
Requirement already satisfied: future in c:\python37\lib\site-packages (from textfsm<2.0.0,>=1.1.0->ntc-templates->netmiko) (0.18.2)
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: pycparser, cffi, pynacl, cryptography, bcrypt, textfsm, paramiko, tenacity, scp, ntc-templates, netmiko
Successfully installed bcrypt-3.2.0 cffi-1.15.0 cryptography-36.0.0 netmiko-3.4.0 ntc-templates-3.0.0 paramiko-2.8.1 pycparser-2.21 pynacl-1.4.0 scp-0.14.1 tenacity-8.0.1 textfsm-1.1.2

可見 netmiko 的相依套件共有 10 個, 如果要離線安裝 netmiko 必須逐一下載 : 
但離線安裝第一個相依檔案 ntc-templates 就出現如下錯誤訊息 : 

E:\netmiko>pip install ntc_templates-1.0.0.tar.gz
Processing e:\netmiko\ntc_templates-1.0.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\kismc\AppData\Local\Temp\pip-17ff54pr-build\setup.py", line 34, in <module>
        os.symlink('../templates', 'ntc_templates/templates')
    OSError: symbolic link privilege not held

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\kismc\AppData\Local\Temp\pip-17ff54pr-build\

查詢原因似乎跟權限有關, 但不管是命令提示字元視窗還是 Thonny, 以管理員權限開啟後安裝此套件都出現同樣錯誤, 在線安裝都沒有問題, 奇怪. 想想工作自動化並非當務之急 (現在做事都考慮急重優先, 輕緩殿後, 先做對的事), 不需要浪費時間在此, 所以先做個紀錄後快閃. 

沒有留言 :