This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Import error for multiprocessing in 2.7rc2 on Windows
Type: crash Stage:
Components: Build Versions: Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, brett.cannon, eric.araujo, jnoller, loewis, ot, paul.moore
Priority: release blocker Keywords: patch

Created on 2010-07-02 13:43 by ot, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mp.diff paul.moore, 2010-07-03 08:58
Messages (8)
msg109109 - (view) Author: Giuseppe Ottaviano (ot) Date: 2010-07-02 13:43
With a fresh install from python-2.7rc2.amd64.msi (rc1 is also affected) multiprocessing gives the following error:

Python 2.7rc2 (r27rc2:82154, Jun 22 2010, 21:22:29) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> multiprocessing.Pool()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\multiprocessing\__init__.py", line 227, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild)
  File "C:\Python27\lib\multiprocessing\pool.py", line 89, in __init__
    self._setup_queues()
  File "C:\Python27\lib\multiprocessing\pool.py", line 181, in _setup_queues
    from .queues import SimpleQueue
  File "C:\Python27\lib\multiprocessing\queues.py", line 22, in <module>
    from multiprocessing.synchronize import Lock, BoundedSemaphore, Semaphore, Condition
  File "C:\Python27\lib\multiprocessing\synchronize.py", line 22, in <module>
    from multiprocessing.forking import assert_spawning, Popen
  File "C:\Python27\lib\multiprocessing\forking.py", line 158, in <module>
    from ._multiprocessing import win32, Connection, PipeConnection
ImportError: No module named _multiprocessing

I noticed that _multiprocessing.lib is not in Lib/multiprocessing/ but in libs/, so I don't know why there is a relative import here.
Changing all the occurrences to
  from _multiprocessing import ...
everything works fine.
msg109125 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-07-02 20:05
Martin, any ideas?
msg109163 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-07-03 08:37
Here is the problem: there is no module multiprocessing._multiprocessing; _multiprocessing is a global module. However, multiprocessing/__init__.py imports _multiprocessing, providing multiprocessing._multiprocessing as a valid attribute. sys.modules['multiprocessing._multiprocessing'] is None.

Now, on Windows, for some reason,

from ._multiprocessing import win32

is used. In 2.6, this used to work. In 2.7, due to r81380, it stopped working (i.e. if I revert r81380, it works again). Adding Brett to the nosy list, as he made this change.
msg109164 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2010-07-03 08:43
Martin's analysis (and the description of the commit he refers to) indicates that the correct fix is Cuiseppe's suggestion to change the relative imports to absolute:

from _multiprocessing import ...

as the previous code was only working because, as a result of the bug fixed in r81380, from ._multiprocessing was falling back to this form anyway.
msg109165 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2010-07-03 08:58
Here's a patch implementing the suggested change. test_multiprocessing passes. I am just running the full test suite now.
msg109169 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2010-07-03 09:21
Full test suite also looks OK.
msg109178 - (view) Author: Jesse Noller (jnoller) * (Python committer) Date: 2010-07-03 12:15
the patch looks good to me - unless someone beats me to it, I'm going to commit it shortly to fix 2.7
msg109180 - (view) Author: Jesse Noller (jnoller) * (Python committer) Date: 2010-07-03 12:26
Pushed it in r82489 - worked for me on Linux and OS/X. Please let me know if anything else comes up.
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53390
2010-07-03 12:26:47jnollersetstatus: open -> closed

messages: + msg109180
2010-07-03 12:15:43jnollersetmessages: + msg109178
2010-07-03 09:21:23paul.mooresetmessages: + msg109169
2010-07-03 08:58:09paul.mooresetfiles: + mp.diff
keywords: + patch
messages: + msg109165
2010-07-03 08:43:21paul.mooresetnosy: + paul.moore
messages: + msg109164
2010-07-03 08:37:14loewissetnosy: + brett.cannon
messages: + msg109163
2010-07-03 03:39:24ncoghlansetnosy: + jnoller
2010-07-02 20:05:25benjamin.petersonsetnosy: + loewis
messages: + msg109125
2010-07-02 14:02:33eric.araujosetnosy: + eric.araujo
resolution: accepted
components: + Build, - Library (Lib)
2010-07-02 14:01:13georg.brandlsetpriority: high -> release blocker
2010-07-02 14:01:06georg.brandlsetpriority: normal -> high
assignee: benjamin.peterson

nosy: + benjamin.peterson
2010-07-02 13:43:14otcreate