You are not logged in.
When I try to work with multiprocessing with python2 I keep getting ImportError. So I tried to run multiprocessing test...
$ python2 /usr/lib/python2.7/test/test_multiprocessing.py...and it worked well. So I made a copy of test_multiprocessing.py to another folder and I got this:
Traceback (most recent call last):
File "test_multiprocessing.py", line 20, in <module>
_multiprocessing = test_support.import_module('_multiprocessing')
File "/usr/lib/python2.7/test/test_support.py", line 79, in import_module
return importlib.import_module(name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/franki/multiprocessing.py", line 27, in <module>
test_support.import_module('multiprocessing.synchronize')
File "/usr/lib/python2.7/test/test_support.py", line 81, in import_module
raise unittest.SkipTest(str(msg))
unittest.case.SkipTest: No module named synchronizeAccording to the python documentation, synchronize fails to import if your operating system does not support a shared semaphore, but then the test wouldn't run either.
What am I missing?
Last edited by Pajaro (2011-09-18 11:08:42)
Offline
Why don't you show the actual ImportError which you're getting while trying to work with multiprocessing?
Offline
This is the code from the first example in the python documentation http://docs.python.org/library/multiprocessing.html
from multiprocessing import Process
def f(name):
print 'hello', name
if __name__ == '__main__':
p = Process(target=f, args=('bob',))
p.start()
p.join()and it outputs:
$ python2 multiprocessing.py
Traceback (most recent call last):
File "multiprocessing.py", line 1, in <module>
from multiprocessing import Process
File "/home/franki/multiprocessing.py", line 1, in <module>
from multiprocessing import Process
ImportError: cannot import name ProcessOffline
@Pajaro: Do the following:
mv multiprocessing.py foo.py
rm *.pyc
python foo.pyNext time please read the error message instead of trying to mess around with some totally unrelated testsuite…
Last edited by lunar (2011-09-19 10:34:14)
Offline
Thank you.
PS: I read the error many times. It is lack of experience understanding python errors.
Offline
Short story: Don't name your .py files the same as some module in stdlib etc. Also, absolute imports ftw.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Yes, I know. I do intentional overrides some times. From my experience, reporting infinite recursion would have been more clear, since self-importing a file doesn't make much sense, because the scope is in the file, so you can refer to self defined elements with no need for imports, and, also, for overrides you have the as keyword (import [somthing] as [something_else]).
Offline