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
Related
$ python
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.request
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'urllib' has no attribute 'request'
>>> urllib.request
<module 'urllib.request' from '/usr/lib/python3.8/urllib/request.py'>
Why is urllib.request recognized as an attribute the second time I try to access it?
To overcome the limitations of pickle, I switched to multiprocessing_on_dill.
This started to generate an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 107, in spawn_main
exitcode = _main(fd)
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 117, in _main
self = reduction.pickle.load(from_parent)
ModuleNotFoundError: No module named '__builtin__'
Is there a way to overcome it?
Surprisingly, it still references C:\ProgramData\Anaconda3\lib\multiprocessing\.
While multiprocessing_on_dill has its own folder C:\ProgramData\Anaconda3\Lib\site-packages\multiprocessing_on_dill with the same set of files.
I'd suggest you use multiprocess instead of multiprocessing_on_dill... the former is better supported, and maintained by the dill author (me). It looks like multiprocess_on_dill is looking for __builtin__, which is where the builtin functions lived in python 2... in python 3, they are in builtins
>$ python
Python 2.7.16 (default, Apr 1 2019, 14:50:56)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
>>>
>$ python
Python 3.6.8 (default, Dec 30 2018, 13:04:41)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '__builtin__'
>>> import builtins
>>>
So, I think it's either you are running python 3, and using the python 2 version of the code -- or the module doesn't fully support python 3.
I am going through the python tutorial and seem to be missing something very basic. The tutorial has:
>>> import site
>>> site.getusersitepackages()
'/home/user/.local/lib/python3.2/site-packages'
But I get the following:
$ python
Python 2.6.8 (unknown, Jun 9 2012, 11:30:32)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> site.getusersitepackages()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getusersitepackages'
As it says above, I am running Python 2.6.8 on cygwin.
Is this installation error?
According to the docs, this feature/function was added in python2.7 -- You're still on python 2.6
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.
When I import the igraph package in my project, I get an AttributeError. This only happens in the project directory:
[12:34][~]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>
[12:34][~]$ cd projectdir/
[12:34][projectdir]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/igraph/__init__.py", line 42, in <module>
import gzip
File "/usr/lib/python2.7/gzip.py", line 36, in <module>
class GzipFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'
>>>
There is no file igraph.py in the project directory:
[12:34][projectdir]$ ls -alR | grep igraph | wc -l
0
And there are no circular imports.
How can I solve this error?
Most likely, there is a module io in ~/projectdir or one of the paths the project configures. The gzip module imported by igraph starts with
import io
and expect the built-in io module, not your project's one. Look for an io directory, or io.py or io.pyc. It can also help to scrutinize sys.path for any other directories (maybe outside of ~/projectdir) that might contain modules named io.