Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: easysnmp/interface.so: undefined symbol: netsnmp_transport_config_compare #12

Closed
mlammon opened this issue Jun 5, 2015 · 16 comments

Comments

@mlammon
Copy link

mlammon commented Jun 5, 2015

Hi Fotis,

I moved this issue off email and into your formal support at your request.
I have python 2.6.6 and I installed easysnmp using pip as requested

pip install easysnmp

Any idea why the error?

Thanks,
Mike

# pwd
/usr/lib64/python2.6/site-packages
[root@scaleha-chef site-packages]# ls -ltr | grep easy
drwxr-xr-x   2 root root   4096 Jun  5 11:31 easysnmp
drwxr-xr-x   2 root root   4096 Jun  5 11:31 easysnmp-0.2.2-py2.6.egg-info

# python
Python 2.6.6 (r266:84292, Jun  5 2015, 10:33:19)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from easysnmp import Session
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "easysnmp/__init__.py", line 1, in <module>
    from .easy import (  # noqa
  File "easysnmp/easy.py", line 3, in <module>
    from .session import Session
  File "easysnmp/session.py", line 8, in <module>
    from . import interface
ImportError: easysnmp/interface.so: undefined symbol: netsnmp_transport_config_compare
>>>
# python --version
Python 2.6.6
@fgimian
Copy link
Collaborator

fgimian commented Jun 5, 2015

Yep, the reason this is likely happening is that you're not running net-snmp 5.7.x. Please upgrade your Net-SNMP libraries to 5.7.2 or 5.7.3 and everything should work correctly.

Cheers
Fotis

@nnathan
Copy link
Contributor

nnathan commented Jun 6, 2015

What version of net-snmp are you currently running? I'm tempted to see if I can get it supported in the C backend.

@fgimian
Copy link
Collaborator

fgimian commented Jun 6, 2015

@nnathan worth a shot, but don't forgot, we have OSs shipping with versions as old as 5.4. It may be quite a challenge to support them all (but worthwhile if not too much work). 😄

@mlammon
Copy link
Author

mlammon commented Jun 6, 2015

net-snmp-devel-5.5-50.el6_6.1.x86_64 is the package currently on the system

yum install net-snmp-devel
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
Setting up Install Process
Package 1:net-snmp-devel-5.5-50.el6_6.1.x86_64 already installed and latest version

@mlammon
Copy link
Author

mlammon commented Jun 10, 2015

I installed 5.7.3. I believe its installed correctly but I am still facing the same error trying to use this easysnmp module

which snmpget

/usr/local/bin/snmpget

/usr/local/bin/snmpget --version

NET-SNMP version: 5.7.3

@fgimian
Copy link
Collaborator

fgimian commented Jun 12, 2015

You'll need to ensure that you re-install the package via pip after installing the latest version of Net-SNMP. Further to this, you'll need to ensure that easysnmp is using the correct header files and libraries for the new version of Net-SNMP which you have installed.

The following code in setup.py configures your libdirs. You may wish to use the print statement after this code to confirm that the correct paths are being detected:

# If a base directory has been provided, we use it
if in_tree:
    netsnmp_libs = os.popen(basedir + '/net-snmp-config --libs').read()

    libdir = os.popen(
        basedir + '/net-snmp-config --build-lib-dirs ' + basedir).read()
    incdir = os.popen(
        basedir + '/net-snmp-config --build-includes ' + basedir).read()

    libs = re.findall(r' -l(\S+)', netsnmp_libs)
    libdirs = re.findall(r' -L(\S+)', libdir)
    incdirs = re.findall(r' -I(\S+)', incdir)

# Otherwise, we use the system-installed SNMP libraries
else:
    netsnmp_libs = os.popen('net-snmp-config --libs').read()

    libs = re.findall(r' -l(\S+)', netsnmp_libs)
    libdirs = re.findall(r' -L(\S+)', netsnmp_libs)
    incdirs = []

Good luck
Fotis

@nnathan
Copy link
Contributor

nnathan commented Jun 12, 2015

I think this will only handle the case of compiling and installing the module. When Python runs, it will also need to load /usr/local/lib/libsnmp.so BEFORE /usr/lib/libsnmp.so (if I understand correctly, you have two versions installed). In that case you will need to configure the runtime linker to load from /usr/local/lib first, so I think that would involve something like LD_PRELOAD=/usr/local/lib/libsnmp.so python (or something in that vein) so that Python uses the newer version of the library.

@fgimian
Copy link
Collaborator

fgimian commented Jun 28, 2015

@mlammon any update on this? I'll be closing the issue in a few days as I'm assuming you've got it all working 😄

@mlammon
Copy link
Author

mlammon commented Jun 28, 2015

Thanks Fotis. You can close it by I never did resolve it. It's ok though

On Jun 28, 2015, at 3:11 AM, Fotis Gimian notifications@github.com wrote:

@mlammon any update on this? I'll be closing the issue in a few days as I'm assuming you've got it all working


Reply to this email directly or view it on GitHub.

@fgimian
Copy link
Collaborator

fgimian commented Jun 28, 2015

@mlammon OK, I do suspect this is an issue with your install of Net-SNMP as we have gotten it working perfectly. Perhaps try again on a fresh system. I'll close this for now, but feel free to open a new issue if you encounter further dramas that you suspect relate to the package itself.

@fgimian fgimian closed this as completed Jun 28, 2015
@nnathan nnathan self-assigned this Jul 16, 2015
@nnathan
Copy link
Contributor

nnathan commented Jul 16, 2015

I have been experiment with running easysnmp on OSX where the original problem manifested.

The fix is actually incredibly simple and requires a slight modification of setup.py in how it parses the net-snmp-config --libs output. I also want to make sure the full test suite runs correctly.

Once I have sorted this out, I will be happy to say that we do infact support Net-SNMP 5.6 which seems to ship with the latest versions of OSX (10.8, 10.9), and push out a new version.

So @mlammon: not sure if you're still interested, but bear with me :).

@nnathan nnathan reopened this Jul 16, 2015
nnathan added a commit that referenced this issue Jul 16, 2015
Support for Net-SNMP 5.6.x and OSX closing issue #12.
@nnathan
Copy link
Contributor

nnathan commented Jul 16, 2015

I ran the test suite against the local running snmpd agent which seems somewhat broken in OSX.

In OSX I would run: sudo -i snmpd -f -Le -d -C -cpwd/easysnmp/tests/snmpd.conf.

Followed by running py.test in the easysnmp directory.

These are the results:

Results (52.41s):
     151 passed
       6 failed
         - /Users/naveen/code/easysnmp/tests/test_easy.py:215: assert '.1.3.6.1.4.1.8072.3.2.255' == '.1.3.6.1.4.1.8072.3.2.10'
         - /Users/naveen/code/easysnmp/tests/test_easy.py:215: assert '.1.3.6.1.4.1.8072.3.2.255' == '.1.3.6.1.4.1.8072.3.2.10'
         - /Users/naveen/code/easysnmp/tests/test_easy.py:215: assert '.1.3.6.1.4.1.8072.3.2.255' == '.1.3.6.1.4.1.8072.3.2.10'
         - /Users/naveen/code/easysnmp/easysnmp/session.py:467: EasySNMPTimeoutError: timed out while connecting to remote host
         - /Users/naveen/code/easysnmp/easysnmp/session.py:467: EasySNMPTimeoutError: timed out while connecting to remote host

This seems to be an issue that's limited to OSX whereby the snmpd will segfault after an interface.walk() test is performed. Until we can get a multi-OS build running in travis, I don't think it is worth doing unit tests in OSX since the shipped version of snmpd seems broken. Having said that, I'm highly confident that easysnmp should work just as good as the Linux version, since the issue is with the daemon and not the client libraries.

I'm now closing this issue again, now that it has been sorted once and for all.

@nnathan nnathan closed this as completed Jul 16, 2015
@ghost
Copy link

ghost commented Jan 13, 2016

I'm using Ubuntu 12 and can reproduce this problem. I installed net-snmp 5.7.3 from source. I believe the problem is related to not being able to locate the libnetsnmp.so given that is where the symbol is located.

You can run this command: LD_PRELOAD=/usr/local/lib/libnetsnmp.so python
and see there is no problem. I suppose the configuration for where python should load libraries varies across systems which is why this problem occurs.

I hope this helps future users of this great python library.

@jdub982
Copy link

jdub982 commented Jun 6, 2016

@normanuber Is there a way to permanently place /usr/local/lib/netsnmplib.so into the LD_LIBRARY_PATH?

Trying to avoid having to have LD_PRELOAD=/usr/local/lib/libnetsnmp.so python in the execution command for my script.

Thanks in advance.

@xiaotuanyu120
Copy link

@normanuber really the same ask like jdub982, how do we to load the correct /usr/local/lib/libnetsnmp.so permanently?

@bdurant
Copy link

bdurant commented Apr 13, 2017

This issue happens on Red Hat Enterprise Linux Server release 6.6 (Santiago).

I have to manually do the following in order for easysnmp to work as expected:

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)

$ /usr/local/bin/snmpget --version
NET-SNMP version: 5.7.3

$ /usr/local/bin/python3.6 -c 'import easysnmp'
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/easysnmp/init.py", line 1, in
from .easy import ( # noqa
File "/usr/local/lib/python3.6/site-packages/easysnmp/easy.py", line 3, in
from .session import Session
File "/usr/local/lib/python3.6/site-packages/easysnmp/session.py", line 8, in
from . import interface
ImportError: /usr/local/lib/python3.6/site-packages/easysnmp/interface.cpython-36m-x86_64-linux-gnu.so: undefined symbol: netsnmp_transport_config_compare

$ export LD_PRELOAD=/usr/local/lib/libnetsnmp.so

$ /usr/local/bin/python3.6 -c 'import easysnmp'

Is this going to be fixed so that we don't have to depend on doing the LD_PRELOAD?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants