Pythonライブラリの再設定
回答済み環境
Kompira:1.6.2.post1
OS:CentOS7.8
Python3.6:yumインストール(後から)
インストールパス:/usr/bin/
Python3.7:ソールからインストール
インストールパス:/usr/local/bin/
Kompiraが動作している環境で別のツールを動作させるため、Python3.7をソールからインストールしました。別のツールの動作にnetmikoも必要だったためpipで別途インストールしています。
Python3.7をインストールする際に、パッケージで管理したくyumでインストール済みのPython3.6を一度削除してしまいました。そのあと、Kompiraの管理画面が動かないことを確認し、yumでPython3.6をインストールしました。
Kompira上からnetmikoを利用したジョブフローを作成し実行したところ以下のエラーが表示られます。
-----
ERROR: task failed: show_users: socket.gaierror: [Errno -2] Name or service not known Traceback (most recent call last):
-----
Kompiraからnetmikoが利用できずに出たエラーかと思っており、yumでインストールされているPython3.6にpipでインストールしようとしたのですが、こちらは環境の問題か、pipでSSLのエラーが出てインストールが出来ませんでした。
Kompiraで使用するPython及び、Pythonライブラリの再構築方法をご教示いただけませんでしょうか。また、その際にソールからインストールしているPython3.7に影響があるよな注意点がございましたら、合わせてご教示いただけますでしょうか。
-
フィックスポイントの高橋です。
Kompira の環境が破損してしまっている可能性が考えられます。
一度 Kompira の再インストールを試してみていただくことは可能でしょうか。このときインストールされている Python 3.7 を利用してしまう可能性がありますので、install.sh を実行する際に環境変数 PYTHON で明示的に Python 3.6 のパスを指定するようにしてみてください。
# PYTHON=/usr/bin/python3.6 ./install.sh
なお、Kompira はインストール時に独自の Python 環境を作成しますので、Python 3.7 環境に影響をあたえることはないはずです。
-
ご確認ありがとうございます。
頂いたコマンドを実行したのですが、以下のエラーが表示されます。ご確認いただけますでしょうか。
ERROR: Command errored out with exit status 1: /opt/kompira/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ucm3u16m/mod-wsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ucm3u16m/mod-wsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pwahrqv4/install-record.txt --single-version-externally-managed --compile --install-headers /opt/kompira/include/site/python3.7/mod-wsgi Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/opt/kompira/bin/python3.7 -m pip install --upgrade pip' command.
[2022-01-25 17:04:56] VERBOSE: status=1
[2022-01-25 17:04:56] VERBOSE: run: rm -rf /tmp/tmp.lbm3zNWayd
[2022-01-25 17:04:56] ERROR:
[2022-01-25 17:04:56] ERROR: Failed to install Kompira package
[2022-01-25 17:04:56] ERROR:
[2022-01-25 17:04:56] ****:
[2022-01-25 17:04:56] ****: Finish: Install the Kompira (status=1)
[2022-01-25 17:04:56] ****: **************************************************************** -
リネームして、再度実行しましたが結果変わらずです。
インストールログを全部添付したほうがよろしいでしょうか。
以下のところからこけているようです。gcc -pthread -shared build/temp.linux-x86_64-3.7/src/server/wsgi_thread.o build/temp.linux-x86_64-3.7/src/server/mod_wsgi.o build/temp.linux-x86_64-3.7/src/server/wsgi_buckets.o build/temp.linux-x86_64-3.7/src/server/wsgi_memory.o build/temp.linux-x86_64-3.7/src/server/wsgi_interp.o build/temp.linux-x86_64-3.7/src/server/wsgi_restrict.o build/temp.linux-x86_64-3.7/src/server/wsgi_logger.o build/temp.linux-x86_64-3.7/src/server/wsgi_server.o build/temp.linux-x86_64-3.7/src/server/wsgi_convert.o build/temp.linux-x86_64-3.7/src/server/wsgi_metrics.o build/temp.linux-x86_64-3.7/src/server/wsgi_validate.o build/temp.linux-x86_64-3.7/src/server/wsgi_daemon.o build/temp.linux-x86_64-3.7/src/server/wsgi_apache.o build/temp.linux-x86_64-3.7/src/server/wsgi_stream.o -o build/lib.linux-x86_64-3.7/mod_wsgi/server/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so -L/usr/local/lib -L/usr/local/lib/python3.7/config-3.7m-linux -lpython3.7m
/bin/ld: /usr/local/lib/libpython3.7m.a(abstract.o): relocation R_X86_64_32S against symbol `_Py_NotImplementedStruct' can not be used when making a shared object。 -fPIC を付けて再コンパイルしてください。 -
ファイル添付の仕方がわからずログを全部貼り付けます。
[2022-01-25 17:26:07] ****: ****************************************************************
[2022-01-25 17:26:07] ****: Kompira-1.6.2.post1:
[2022-01-25 17:26:07] ****: Start: Install the Kompira
:
[2022-01-25 17:26:12] INFO: Confirmed Python version: Python 3.7.9
[2022-01-25 17:26:12] INFO: PYTHON=/usr/local/bin/python3.7
:
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/kompira/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oy3i80ge/mod-wsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oy3i80ge/mod-wsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-n6s9ol04/install-record.txt --single-version-externally-managed --compile --install-headers /opt/kompira/include/site/python3.7/mod-wsgi Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/opt/kompira/bin/python3.7 -m pip install --upgrade pip' command.
[2022-01-25 17:27:16] VERBOSE: status=1
[2022-01-25 17:27:16] VERBOSE: run: rm -rf /tmp/tmp.MJwUiulEnl
[2022-01-25 17:27:16] ERROR:
[2022-01-25 17:27:16] ERROR: Failed to install Kompira package
[2022-01-25 17:27:16] ERROR:
[2022-01-25 17:27:16] ****:
[2022-01-25 17:27:16] ****: Finish: Install the Kompira (status=1)
[2022-01-25 17:27:17] ****: **************************************************************** -
頂いたコマンドを実行したところ以下のようになりました。
:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-vlby3iht/cryptography/setup.py", line 14, in <module>
from setuptools_rust import RustExtension
ModuleNotFoundError: No module named 'setuptools_rust'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vlby3iht/cryptography/
You are using pip version 9.0.3, however version 21.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
: -
以下のように再インストールは完了しました。
[2022-01-26 10:33:55] ****: Finish: Install the Kompira (status=0)
ただ、外部機器にアクセスしようとすると同じエラーが出ます。
まだ何だ設定が足りない状況でしょうか。<special variables> $ENV = {} $ERROR = "aborted at line 28 in /root/xxxxTest: 'show_users' failed: socket.gaierror: [Errno -2] Name or service not known" $RESULT = '' $STATUS = 1
動作確認中でジョブフローは以下のサイトのものをそのままコピーして作成しました。
https://support.kompira.jp/column/use_netmiko/ -
ご連絡ありがとうございます。インストールは成功したようでなによりです。
おそらくですが、Kompira としては正常に動作できるようになったのではないかと思います。ジョブフローのエラーですが、こちらはライブラリから外部機器にアクセスするときに機器のアドレスが解決できないなど、なんらかの理由でエラーになっているのかと思われます。
一度、ジョブフローからではなく、Kompira サーバ上で python を起動して、そこで以下のようにライブラリと同様の処理を実行させてみて、なにかエラーが出るか確認してみていただけますでしょうか。
# /opt/kompira/bin/python
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from netmiko import Netmiko
>>> data={'device_type':'cisco_ios_ssh','ip':'XX.XX.XX.XX','port':'22','username':'admin','password':'********'}
>>> conn=Netmiko(**data)
>>> print(conn.send_command('show users'))
Line User Host(s) Idle Location
* 2 vty 0 admin idle 00:00:00 YY.YY.YY.YY
Interface User Mode Idle Peer Address
>>>
サインインしてコメントを残してください。
コメント
14件のコメント