vincentbernat / snimpy

interactive SNMP tool with Python
http://snimpy.readthedocs.org/
185 stars 44 forks source link

Installation snimpy error on AlmaLinux 8.6 #99

Closed sgelineau17 closed 2 years ago

sgelineau17 commented 2 years ago

Hello,

I try to install snimpy on my new AlmaLinux 8.6 VM but the installation is failed.

The OS are full update, gcc are installed and all of dev librairie whose libsmi. I use python 3.6.8.

The VM have been restart but I always this error message :

[root@******* ~]# pip3 install --user --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org  snimpy
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting snimpy
  Downloading https://files.pythonhosted.org/packages/cd/47/f8b562ae49bb53f5e5858c133a6865718301d96d29d1ea4493f7ad186ade/snimpy-1.0.0.tar.gz (76kB)
    100% |████████████████████████████████| 81kB 12.6MB/s 
Requirement already satisfied: cffi>=1.0.0 in /usr/local/lib64/python3.6/site-packages (from snimpy)
Requirement already satisfied: pysnmp>=4 in /usr/local/lib/python3.6/site-packages (from snimpy)
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from snimpy)
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi>=1.0.0->snimpy)
Requirement already satisfied: pysmi in /usr/local/lib/python3.6/site-packages (from pysnmp>=4->snimpy)
Requirement already satisfied: pyasn1>=0.2.3 in /usr/local/lib/python3.6/site-packages (from pysnmp>=4->snimpy)
Requirement already satisfied: pycryptodomex in /usr/local/lib64/python3.6/site-packages (from pysnmp>=4->snimpy)
Requirement already satisfied: ply in /usr/lib/python3.6/site-packages (from pysmi->pysnmp>=4->snimpy)
Installing collected packages: snimpy
  Running setup.py install for snimpy ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-6xsx06h4/snimpy/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-cjw33p6h-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'pbr'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/__init__.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/__main__.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/_version.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/basictypes.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/config.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/main.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/manager.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/mib.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/smi_build.py -> build/lib.linux-x86_64-3.6/snimpy
    copying snimpy/snmp.py -> build/lib.linux-x86_64-3.6/snimpy
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.6/snimpy._smi.c'
    creating build/temp.linux-x86_64-3.6
    building 'snimpy._smi' extension
    creating build/temp.linux-x86_64-3.6/build
    creating build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c build/temp.linux-x86_64-3.6/snimpy._smi.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/snimpy._smi.o
    build/temp.linux-x86_64-3.6/snimpy._smi.c:570:10: fatal error: smi.h: No such file or directory
     #include <smi.h>
              ^~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-6xsx06h4/snimpy/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-cjw33p6h-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-6xsx06h4/snimpy/

Thanks a lot !

vincentbernat commented 2 years ago

It looks like it does not find libsmi development files (I suppose this should libsmi-devel). Are they installed? rpm -qa | grep libsmi

sgelineau17 commented 2 years ago

Hello,

The package are installed.

image

Thanks

vincentbernat commented 2 years ago

That's not the devel package (the one containing the headers)

sgelineau17 commented 2 years ago

Oh ok, I undestand, I don't find it when I run a "dnf search libsmi", I only have this :

image

sgelineau17 commented 2 years ago

Ok, I'm sorry, on AlmaLinux (not on Rocky, CentOS...) the repository "Powertools" was not enable by default, I enable it and I have installed libsmi-devel.

My other problem is when I try to start my python script, I obtained this error message :

/usr/bin/env: ‘snimpy’: No such file or directory

Do you have an idea ?

`#!/usr/bin/env snimpy

from pprint import pprint as pp

import ipaddress import pickle

ips = [ 'IP RT 1', 'IP RT 2', ]

load('IF-MIB')

status = {}

for ip in ips: ipaddress.IPv4Address(ip) #test if valid ip address pp(ip)

    status[ip] = {}

    with M(
            host=ip,
            version=2,
            community='COMMUNITY',
    ) as m:
            for id in m.ifIndex:
                    #pp(id)

                    status[ip][int(id)] = {
                            'admin_status': str(m.ifAdminStatus[id]),
                            'alias': str(m.ifAlias[id]),
                            'descr': str(m.ifDescr[id]),
                            'last_change': str(m.ifLastChange[id]),
                            'oper_status': str(m.ifOperStatus[id]),
                            'speed': str(m.ifSpeed[id]),
                            'type': str(m.ifType[id]),
                    }

pp(status)

with open('status_nexus.pkl', 'wb') as f: pickle.dump(status, f, pickle.HIGHEST_PROTOCOL)`

Je m'embête à te parler Anglais alors que tu es Français :)

vincentbernat commented 2 years ago

With --user, I suppose it gets installed in ~/.local/bin. This should be added to your path for this to work.

sgelineau17 commented 2 years ago

I just checked indeed, it seems to be present in ~/.local/bin

image

I have try my run my script with --user but it's not working.

image

Thanks for your help !

vincentbernat commented 2 years ago

What's echo $PATH?

sgelineau17 commented 2 years ago

Here is the answer

image

vincentbernat commented 2 years ago

So, ~/.local/bin is not in it. export PATH=$PATH:~/.local/bin.

sgelineau17 commented 2 years ago

Thanks a lot ! subject can be closed