LoginSignup
0
0

Windows上のPythonとJupyter/Ipythonでのマルチプロセッシング - 動作させるために(翻訳まとめ)

Posted at

記事:Multiprocessing in Python on Windows and Jupyter/Ipython — Making it work

現象

Windows上だとpythonシェル(cmd → python)で実行すると以下のエラーが発生する。

Can't get attribute 'worker' on <module '__main__' (built-in)> 

Windows + Jupyter上でこのコードを実行すると、永遠に固まったまま処理が完了しない。

なぜ、うまく動作しないのか?

JupyterとWindowsの相性が悪い

解決法は?

2つの簡単な修正を加えるだけで問題なく動くようになる。

  • 関数などの定義を 別の .py ファイルで定義 してインポートする。
  • 呼び出す前に if __name == '__main__' 節を追加する。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0