I have an application in Python 2.5 that listens to a beanstalk queue. It works fine on all machines I tested so far, except from my newly acquired MacBook Pro.
On that computer, when I try to run it I get this error:
Traceback (most recent call last):
File "jobs.py", line 181, in <module>
Jobs().start()
File "jobs.py", line 154, in start
self.jobQueue = Queue()
File "src/utils/queue.py", line 16, in __init__
self.connection = serverconn.ServerConn(self.server, self.port)
File "src/beanstalk/serverconn.py", line 25, in __init__
self.poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
The serverconn.py has the following imports:
import socket, select
And when I try to run it from command line, it fails as well:
Python 2.5.1 (r251:54863, Jul 23 2008, 11:00:16)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> select.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
Do you have any idea on what can be happening?
PS: Even though I am pretty confident it's not a source problem, if you need some background on the source that's failing, it's available at [http://pastie.org/399342](this pastie).
Updated: since the first answer I got speculates whether select.poll() is or not supported on Mac OS, but I have an iMac too and with the exact same OS version and it works fine:
2009-02-25 00:27:10,067 - Queue - DEBUG - Connecting to BeansTalk daemon # localhost:11300
According to this macports ticket Apple's implementation of poll() is straight up broken. Apple worked around this by disabling poll() in Python and macports now disables poll in their Pythons as well. I think this means you need to look into Python's select.kevent() instead of poll on mac.
I think your answer is here
http://atomized.org/2008/12/python-on-os-x-leopard-lacks-selectpoll/
use the MacPorts version of python on your MBP.
Mac OS X supports this. Apple stock Leopard python 2.5.1 does not.
you will want to download and install MacPorts if you have not already. FYI, I find Porticus to be an excellent GUI around MacPorts.
here is a comparison of stock Leopard python vs. latest MacPorts python2.5...
Leopard python from Apple (python 2.5.1) - select.poll() broken
$ /usr/bin/python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
>>>
Macports (python 2.5.4) - select.poll() works!
$ /opt/local/bin/python2.5
Python 2.5.4 (r254:67916, Feb 3 2009, 21:40:31)
[GCC 4.0.1 (Apple Inc. build 5488)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
<select.poll object at 0x11128>
>>>
select.poll()
(Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section Polling Objects below for the methods supported by polling objects.
My guess is that it's not supported on the macOS.
Related
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?
Intel Data Analytics Acceleration Library (Intel DAAL) has been installed successfully on my ubuntu. However, when running examples located at compilers_and_libraries_2017/linux/daal/examples/python/source/distance, I got following error. Anybody have this problem before?
$ source activate intelpython
(intelpython) W2600CR:/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$
$ python3.5
Python 3.5.2 |Intel Corporation| (default, Feb 5 2017, 09:07:18)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>>
(intelpython)$ :/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$ python3.5 cos*.py
Traceback (most recent call last):
File "cos_dist_dense_batch.py", line 48, in <module>
DataSourceIface.doDictionaryFromContext
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 4540, in __new__
return FileDataSource_CSVFeatureManagerFloat64(*args)
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 3534, in __init__
this = _data_management.new_FileDataSource_CSVFeatureManagerFloat64(*args)
SystemError: Error on file open
I ran into the same problem. After I dig into the sample source, I found that it's due to the csv file path.
Just cd to compilers_and_libraries_2017/linux/daal/examples/python and run the sample again.
I have installed python-2.7.5-5ubuntu3 and matplotlib-1.3.1-1ubuntu5 from the ubuntu 14.04 repository via apt-get. Trying to import the library in python 2.7 raises the following import error:
harold#ubuntu:~$ 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 matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/matplotlib/__init__.py", line 157, in <module>
from matplotlib.compat import subprocess
ImportError: No module named compat
>>>
I checked the directory /usr/share/pyshared/matplotlib and, indeed, cannot find any package called compat.
Any idea what is broken on my system?
Thanks!
I have found same problem on Ubuntu 16 & 14.
Possible source of the problem is damaged instance of matplotlib. Damaged instance overlaps working instance of matplotlib.
Please try to remove broken instance of matplotlib to solve the issue.
Firstly I have looked matplotlib instances:
find / |grep matplotlib | grep __init__\.py$ |more
Secondly I have deleted this folder:
find /usr/share/pyshared/matplotlib -delete
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
When I try to use twisted from python it fails to load. Extras path is not in my sys.path. Even when I add it to sys.path it fails to load twisted. Any ideas?
sudo find / -name twisted
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.internet.protocol import Factory
Traceback (most recent call last):
File "test.py", line 1, in <module>
from twisted.internet.protocol import Factory
ImportError: No module named twisted.internet.protocol
Have you made sure that all permissions are set properly? If you installed it by hand it might be a problem with the permissions. Check that the permissions are 644 for files and 755 for directories.