classner / pymp

Easy, OpenMP style multiprocessing for Python on Unix.
MIT License
280 stars 29 forks source link

Running example code snippet fails #11

Closed gergelymathe closed 5 years ago

gergelymathe commented 5 years ago

Recently, I am an issue with using pymp which was not the case previously.

I installed pymp via pip originally. I was able to run the example snippets just as to use the package with my codes. Right now, I am not able to use my codes which were functioning previously. Those return with error. The error is the same as in case of trying to run the example snippet from this site. The example returns the next error message:

from __future__ import print_function

import pymp
ex_array = pymp.shared.array((100,), dtype='uint8')
with pymp.Parallel(4) as p:
    for index in p.range(0, 100):
        ex_array[index] = 1
        # The parallel print function takes care of asynchronous output.
        p.print('Yay! {} done!'.format(index))

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-79-fc2456988e0a> in <module>()
      3 import pymp
      4 ex_array = pymp.shared.array((100,), dtype='uint8')
----> 5 with pymp.Parallel(4) as p:
      6     for index in p.range(0, 100):
      7         ex_array[index] = 1

/home/gergelymathe_linux/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymp/__init__.pyc in __init__(self, num_threads, if_)
     43                 "do this."
     44             )
---> 45         self._num_threads = num_threads
     46         self._enabled = if_
     47         if not self._enabled:

/home/gergelymathe_linux/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymp/shared.pyc in queue(*args, **kwargs)
     45 def dict(*args, **kwargs):  # pylint: disable=redefined-builtin
     46     """Create a shared dict."""
---> 47     return _MANAGER.dict(*args, **kwargs)
     48 
     49 

/home/gergelymathe_linux/Canopy/appdata/canopy-1.7.4.3348.rh5-x86_64/lib/python2.7/multiprocessing/managers.pyc in temp(self, *args, **kwds)
    665             def temp(self, *args, **kwds):
    666                 util.debug('requesting creation of a shared %r object', typeid)
--> 667                 token, exp = self._create(typeid, *args, **kwds)
    668                 proxy = proxytype(
    669                     token, self._serializer, manager=self,

/home/gergelymathe_linux/Canopy/appdata/canopy-1.7.4.3348.rh5-x86_64/lib/python2.7/multiprocessing/managers.pyc in _create(self, typeid, *args, **kwds)
    563         '''
    564         assert self._state.value == State.STARTED, 'server not yet started'
--> 565         conn = self._Client(self._address, authkey=self._authkey)
    566         try:
    567             id, exposed = dispatch(conn, None, 'create', (typeid,)+args, kwds)

/home/gergelymathe_linux/Canopy/appdata/canopy-1.7.4.3348.rh5-x86_64/lib/python2.7/multiprocessing/connection.pyc in Client(address, family, authkey)
    167         c = PipeClient(address)
    168     else:
--> 169         c = SocketClient(address)
    170 
    171     if authkey is not None and not isinstance(authkey, bytes):

/home/gergelymathe_linux/Canopy/appdata/canopy-1.7.4.3348.rh5-x86_64/lib/python2.7/multiprocessing/connection.pyc in SocketClient(address)
    306         s.setblocking(True)
    307         try:
--> 308             s.connect(address)
    309         except socket.error, e:
    310             s.close()

/home/gergelymathe_linux/Canopy/appdata/canopy-1.7.4.3348.rh5-x86_64/lib/python2.7/socket.pyc in meth(name, self, *args)
    226 
    227 def meth(name,self,*args):
--> 228     return getattr(self._sock,name)(*args)
    229 
    230 for _m in _socketmethods:

error: [Errno 2] No such file or directory

I already updated my version of pymp-pypi to 0.4.2 via pip, but it did not solve my problem.

Could you please point me to the right direction?!

classner commented 5 years ago

Hi @gergelymathe,

This issue seems unrelated to pymp and hints at a broken python installation (the error is thrown in the socket module of the python standard library).