wheel: script with multiprocessing doesn't work on Windows
See original GitHub issuesetup.py
from setuptools import setup
setup(
version='0.0.1',
name="blub",
py_modules=["blub"],
entry_points={
'console_scripts': ['blub = blub:main'],
},
)
blub.py
import multiprocessing
def f():
pass
def main():
p = multiprocessing.Process(target=f)
p.start()
p.join()
print 'xxx'
When installing this without wheel, everything is fine:
$ pip install .
$ blub
xxx
Installing this as wheel, the script is broken:
$ pip uninstall blub
$ pip wheel .
$ pip install wheelhouse/*
$ blub
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Python27\Lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "c:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
assert main_name not in sys.modules, main_name
AssertionError: __main__
xxx
This is probably related to http://bugs.python.org/issue10845.
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
Multiprocessing python within frozen script - Stack Overflow
The documentation linked above has an easy fix that redirects all outputs to files. import sys sys.stdout = open(“my_stdout.log”, “w”) sys.
Read more >How to get Python multiprocessing module working on ...
I managed to get multi-processing working on ms-windows, doing some workarounds. sys.executable needs to point to Python executable. The scripts __file__ ...
Read more >Advanced Topics — PyArmor 7.2.0 documentation
Almost all the obfuscated scripts will be run as main script; In the obfuscated scripts call multiprocessing to create new process; Or call...
Read more >Multithreading PyQt5 applications with QThreadPool
Run background tasks concurrently without impacting your UI. A common problem when building Python GUI applications is.
Read more >Installing Ray — Ray 2.2.0 - the Ray documentation
Ray on Windows is currently in beta. Official Releases#. From Wheels#. You can install the latest official version of Ray from PyPI on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PIP-VERSION: 7.1.2 SETUPTOOLS-VERSION: 18.4
This problem is not related to wheel-based installations. This problem exists also when you install a source distribution from a ZIP file. The problem seems to be caused how the
<script>.exe
is created in the “Scripts/” sub-directory. A__main__.py
is archived/embedded in the<script>.exe
executable. Probably thesys.executable
from__main__.py
is not resolved correctly when the multiprocessing.forking module is involved.WORKAROUNDS (alternatives):
easy_install
(setuptools) and everything is fine.<script>.py
in the “Scripts/” directory and everything is fine.EXAMPLE:
MAYBE:
multiprocessing.set_executable(...)
is needed in scripts that use multiprocessing (on Windows) !?!Closing this, this is a bug with Python itself and it appears fixed in 3.x and 2.7.111 so the recommendation is to get a newer Python if you are hitting this.