Python 2 Bindings Net-SNMP Error - undefined symbol: netsnmp-memdup - python

I successfully compiled net-snmp-5.7.3 on Ubuntu. :D This is the specific version of Ubuntu:
Linux loserBox 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
I seemed to have successfully installed the Python bindings for net-snmp too. This is included with the net-nsmp download as a different folder titled 'Python' with the setup.py file in it. However when running the command python setup.py test I noticed some problems. I thought this may be nothing to worry about so I went ahead and executed python setup.py install I was not sure what the instructions meant in the README file that say, "python setup.py test (requires a locally running agent w/ config provided)". So, this is why I installed it with the failed test or something. Anyways, I am not sure if this is a problem or not.
After successfully installing the python bindings for net-snmp I switched directories back to my Desktop and opened up an interactive python shell. From here I imported the netsnmp module and received the below error. It almost looks like there is a spelling error in the variable netsnmp_memdup that is throwing the error in the Traceback. This looks like a problem with the C code and not python.
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning:
/home/loser_user/.python-eggs is writable by group/others and vulnerable to attack
when used with get_resource_filename. Consider a more secure location
(set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/__init__.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 6, in __bootstrap__
ImportError: /home/loser_user/.python-eggs/netsnmp_python-1.0a1-py2.7-linux-x86_64.egg-
tmp/netsnmp/client_intf.so: undefined symbol: netsnmp_memdup
Does anyone know how to fix this problem? I looked on the mailing list page on sourceforge for this project and searched the supoort archives but did not find anything.
Thanks for listening to a crazy man's Python problems.
Happy Holidays,
user_loser

Alrgihty, thanks to my good friend Naveen, we have traced this down to an actual bug in the Python Net-SNMP bindings in the 5.7.3.
There are two ways around this:
Use the Python bindings in Net-SNMP 5.7.2
See this commit on our fork of the Net-SNMP Python library (only started yesterday so bear with us): https://github.com/fgimian/easysnmp/commit/fa86af977b563f65e7d70243752d48b94a8d5686 and replicate this in your download of Net-SNMP.

Related

Python: undefined symbol: TLSv1_method when importing ssl

I'm running Python 3.5.6 on a distribution where TLS versions below 1.2 have been compiled out of OpenSSL by passing these options to ./configure: no-ssl no-tls1 no-tls1_1 no-ssl3-method no-tls1-method no-tls1_1-method. The OpenSSL version is 1.1.1d. Python 3 is built from source at distro build time and linked against the version of OpenSSL included in the distro.
Everything builds successfully, but when I try to import the ssl library in Python, I get the following error:
$ python3
Python 3.5.6 (default, Mar 23 2020, 05:11:33)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/ssl.py", line 99, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: /usr/lib/python3.5/lib-dynload/_ssl.cpython-35m-aarch64-linux-gnu.so: undefined symbol: TLSv1_method
I don't understand why this error occurs at runtime. The only reference I can find in the Python 3.5.6 code to TLSv1_method is line 3088 of _ssl.c:
ctx = SSL_CTX_new(TLSv1_method());
Using no-tls1-method does compile out the implementation of TLSv1_method, and that line in the Python code is not guarded by any #ifdef. But I'd expect that to cause a failure at link time for the _ssl.cpython-35m-aarch64-linux-gnu.so module, not at runtime when Python tries to import the module. What's going on here, and is there a way to fix it without patching Python? I cannot upgrade the version of OpenSSL or Python in use.
It seems that my confusion resulted from misunderstanding how _ssl.cpython-35m-aarch64-linux-gnu.so links to OpenSSL. I assumed that it was statically linked, but it's actually dynamically linked to libssl.so. This is why the error occurs at runtime when the shared object is loaded.
It seems, then, that the only way to fix this without updating Python is to patch the call to TLSv1_method to use the generic TLS_method instead. I'll leave this question open for a few days though in case anyone has a better suggestion.
Edit: I filed a Python bug for this issue. It should be fixed in a future release.

Importing asyncio throws error

In my terminal, I wanted to test something with asyncio. Here's what I did:
$ python3.6
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
And this threw an error as follows:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/__init__.py", line 42, in <module>
tasks.__all__ +
AttributeError: module 'asyncio.tasks' has no attribute '__all__'
Why does it throw this error, and how can I fix it? (I checked in my python 3.5 interpreter the same way and got no error, so maybe the library got corrupted?)
I've run Python with the -v switch, the output produced after running import asyncio at the prompt is rather large, so it is available in this GitHub gist.
Your local installation has been corrupted. From the python -v output you provided:
# bytecode is stale for 'asyncio.tasks'
# code object from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py
import 'asyncio.tasks' # <_frozen_importlib_external.SourceFileLoader object at 0x104cf7860>
The bytecode is stale message means that asyncio/tasks.py file is newer than the accompanying asyncio/__pycache__/tasks.cpython-36.pyc file. This indicates that something has altered the tasks.py file, causing the contents to be different from what was shipped with your Python binary.
For comparison, the sibling module asyncio.events was loaded from the bytecode cache, which was provided by the Python installer at install time:
# code object from '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/__pycache__/events.cpython-36.pyc'
import 'asyncio.events' # <_frozen_importlib_external.SourceFileLoader object at 0x104ccf4e0>
The code object for that module was loaded from the asyncio/__pycache__/events.cpython-36.pyc file.
You could re-install Python from the OS X installer, but at this point I'd just grab the newer 3.6.5 release instead.
You could also try to re-instate the original contents by downloading the original source from the v3.6.2 tag, but then you'll have to make sure the bytecode is regenerated (run sudo python -m compileall /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py) and you'll need to check for any other such changed files (try find /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6 -name \*.py -newer /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/__init__.py)
It seems that it's a bug
Try to upgrade your Python via brew
brew upgrade python3
Currently, Python 3.6.5 is available and there is no such problem

import wx failed under GDB python interface, R6034: An application has made an attempt to load the C runtime library incorrectly

I have a self build GDB.exe under WinXP, which is link against python 2.7 dll. The GDB was built under msys+MinGW, so GDB.exe is linked against msvcrt.dll. But the python dll is linked against msvcrt90.dll. See the screen shot below of the dependency walker.
Generally, the python interpreter in GDB.exe works quite well, and I can correctly run python pretty printer and other python commands.
But I found that the wxPython can not run correctly, see the command log:
GNU gdb (GDB) 7.8.50.20140717-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) python import wx
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\__init__.py", li
ne 45, in <module>
from wx._core import *
File "E:\code\gdb\mybuild\bin\lib\site-packages\wx-3.0-msw\wx\_core.py", line
4, in <module>
import _core_
ImportError: DLL load failed: The specified module could not be found.
Error while executing Python code.
(gdb)
I realize that there are some dlls under folder: E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx, such as "core_.pyd" and "wxmsw30u_core_vc90.dll", these dlls were build from Visual C++, and you can see, they are linked to msvcr90.dll and msvcp90.dll.
But if I run the same command under python.exe (which is E:\code\gdb\mybuild\bin\python.exe) command line shell, there is not such issue, see the log:
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>
Look, I don't have any issue to run import wx command.
I also noticed that the python.exe is build against msvc90.dll, see the dependency walker screen shot below:
Now, my question is: how to solve this issue? From what I know, the two different kind of DLL (msvcrt.dll and msvcrt90.dll) works peacefully, but why I can't use wxpython? Thank you.
OK, the problem is solved. The reason is that both the pyd file and the dll file under the folder E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx need to be associated with a manifest. I manually add the manifest to the pyd file by a tool named Resource Hacker, but I think any tool which can edit the PE file can do this. The pyd file already have some piece of manifest, so I just add more like:
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
For the dll file, I just found there are manifest file in a wxpython development package 32-bit binaries for MSVC 9 from official wxPython site, so I just copy the manifest files to the E:\code\gdb\mybuild\bin\Lib\site-packages\wx-3.0-msw\wx.
I don't have issue now, I can correctly show a wxFrame from GDB's command line.
I have tried the process of ollydbg23. The changes taken effect only after restart.

Local Appengine stopped working

I tried to run one of my AppEnigne projects (python) today but it will no longer launch, this is the stack trace I'm getting.
*** Running dev_appserver with the following flags:
--admin_console_server= --port=8080 --clear_datastore
Python command: /usr/bin/python2.5
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 77, in <module>
run_file(__file__, globals())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 73, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 138, in <module>
import logging
ImportError: No module named logging
I thought it could be a python 2.6 error but I adjusted my path to /usr/bin/python2.5 and its still not working. I'm running OSX 10.6.8 and have the latest AppEngineLauncher 1.5.4
The only thing I changed recently that might have affected this is when I updated my XCode to the latest version, v4.2 build 4C199
Has anyone else faced this issue recently?
EDIT
I can't import logging from the terminal either, same message. Here's Python's path.
Chriss-MacBook-Pro:bin chris$ /usr/bin/python2.5
Python 2.5.4 (r254:67916, Aug 2 2010, 20:09:39)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload',
'/Library/Python/2.5/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-unicode']
>>>
Thanks to Nick and Wobble I've figured it out. I recently updated my XCode install to the 4.2 GM release and removed the beta versions. Along the way OSX forgot where gcc was installed and prevented it from compiling the python modules like logging. This resulted in missing .pyo files inside /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python25/logging which prevents import logging from working.
Logging wasn't the only module that wasn't compiled, just the first one AppEngine tried to import.
Solution: uninstall and do a clean install of XCode. Make sure gcc can be found on your PATH and everything should be fine.

Python 2.5.2 and Solaris 8 (gcc 3.4.2) build issues

I'm trying to build python 2.5.2 on Solaris 8 using gcc 3.4.2. I can't see any immediate errors in the ./configure step but, once built and i enter the python shell doing an import time errors with :
Python 2.5.2 (r252:60911, Nov 21 2008, 18:45:42)
[GCC 3.4.2] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named time
What am i doing wrong? From what i can see with a cursory google is that there might be an error with libstdc++.so, but i can't find any hard details.
Any suggestions would be most welcome.
Many thanks,
Al.
The time module is not built by default in Python, if you build from a source distribution you need to explicitly enable all the modules you want to compile.
Open up Modules/Setup.dist in the python source tree and comment out the line which says:
#time timemodule.c
To enable the build of time module. Also remember that you need to recompile Python for this to take an effect.

Categories

Resources