ImportError: cannot import name asn1 - python

i have installed pysnmp on centos using easy_install,
however when i import asn1 it does not work
[root#server ~]# python
Python 2.4.3 (#1, Jun 18 2012, 08:55:23)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysnmp import asn1
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: cannot import name asn1
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/pysnmp-4.2.2-py2.4.egg', '/usr/lib/python2.4/site-packages/pycrypto-2.6-py2.4-linux-x86_64.egg', '/usr/lib/python2.4/site-packages/pyasn1-0.1.3-py2.4.egg', '/usr/lib64/python24.zip', '/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', '/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', '/usr/lib64/python2.4/site-packages', '/usr/lib64/python2.4/site-packages/gtk-2.0', '/usr/lib/python2.4/site-packages']
>>>
i am trying to run this example http://pysnmp.sourceforge.net/examples/2.x/snmpagent.html
my goal is to read snmp traps sent by other devices and process them on the server.

You're trying to run an example for 2.x with version 4.x of the package. Find a 4.x example instead.

Related

Eventlet breaks select.poll

Eventlet monkey patch seems breaking py3 select.poll() on my ENV (i try to install openstack ironic), But openstack group could not reproduce this issue, anyone knows why?
I can simply reproduce it by:
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
>>>
>>> eventlet.monkey_patch()
>>> import select
>>> select.poll
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'select' has no attribute 'poll'
>>> eventlet.version_info
(0, 25, 0)
>>>
It's intentional, as select.poll() is not "green".
See also: https://github.com/eventlet/eventlet/issues/608#issuecomment-612359458

Cannot use socket

I am trying to import socket and I get the following error:
$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 68, in <module>
from _ssl import \
ImportError: cannot import name RAND_egd
I thought that perhaps my Anaconda installation was corrupted so I uninstalled and reinstalled Anaconda but the error persists.
I had tried what the other posts suggested except for editing socket.py due to Macos System Integrity Protection. My guess is that the problem lies elsewhere as I doubt that everyone has had to edit the file.
How can I find the source of the problem?

Python failing in sub directory, but working in home directory

I have an Ubuntu machine (18.04) on a VM. When I run python in the home directory, everthing responds normally, however when I run from a sub directory it is failing to import modules in the standard library.
The sequence below illustrates the problem
anon#anon-VirtualBox:~$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>import os
>>> os.environ['PATH']
'/bin:/home/anon/anaconda2/bin:/home/anon/bin:/home/anon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
>>> import logging
>>> exit()
Which is the expected behaviour.
However when I go into a subdirectory, the same operation fails
anon#anon-VirtualBox:~$ cd GitHub/bikeano
anon#anon-VirtualBox:~/GitHub/bikeano$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['PATH']
'/bin:/home/anon/anaconda2/bin:/home/anon/bin:/home/anon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
>>> import logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "logging.py", line 5, in <module>
import logging.handlers
ImportError: No module named handlers
>>>
I do not understand what is happening here. Are there other environment variables which could affect this?
Also, this is occuring on a Virtualbox VM, and the same .vdi works normally on another machine? The host is Windows 10 on both machines.

Why do I get a ModuleNotFoundError for winreg on a Linux system?

'winreg' module is not found python 3.6.7. I am not facing this problem in Python 3.4.
Is any third-party app in 'winreg' that I can use same code or how can I solve this.
jaki#jaki-notebook:~$ python3 -V
Python 3.6.7
jaki#jaki-notebook:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from winreg import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'winreg'
>>>
ModuleNotFoundError: No module named 'winreg'
It is not work on linux because this package expose functions of the Windows registry API to Python
Read this documentation on python offical website

Python module import fails when in file but from interpreter works

I have a module that I am unable to import from the import statement in the top of a file, but the same import works fine in the same interpreter.
Any thoughts on this?
➜ ~ python /home/barrett/Git/bnr_robot_software/src/bnr_robot_cloud /bnr_robot_cloud_common/src/bnr_robot_cloud_common/my_unique_script_name.py
Traceback (most recent call last):
File "/home/barrett/Git/bnr_robot_software/src/bnr_robot_cloud/bnr_robot_cloud_common/src/bnr_robot_cloud_common/my_unique_script_name.py", line 1, in <module>
from azure.servicebus import ServiceBusService
ImportError: No module named servicebus
➜ ~ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from azure.servicebus import ServiceBusService
>>>

Categories

Resources