Giter Site home page Giter Site logo

Comments (4)

sgbaird avatar sgbaird commented on August 29, 2024

Python multiprocessing RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase

Multiprocessing usually doesn't work in a console/ide in Windows. When using a spawning system instead of fork, python must import modules and create state in the child process to get things to work. If you do not protect your outer script with a if name=="main": clause, you get this problem.

from elm2d.

sgbaird avatar sgbaird commented on August 29, 2024

However, what's odd is the ElM2D does seem to have this:

ElM2D/ElM2D/ElM2D.py

Lines 510 to 511 in 7c82fdc

if __name__ == "__main__":
main()

Another related SE post:
https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Is it possible that the pip-installed version didn't include the if __name__ == "__main__": clause?

from elm2d.

sgbaird avatar sgbaird commented on August 29, 2024

(Spyder maintainer here) Multiprocessing doesn't work well on Windows in Spyder's IPython console. However, you can run your code in an external terminal to have the results you want.

To do that, please go to

Run > Configuration per file > Execute in an external system terminal
https://stackoverflow.com/a/48099756/13697228

from elm2d.

sgbaird avatar sgbaird commented on August 29, 2024

Also related: https://stackoverflow.com/a/52768747/13697228

I was able to get it working by making a "test" function as follows:

from multiprocessing import freeze_support
from os.path import join
import pandas as pd
from ElM2D import ElM2D

def main():
    mapper = ElM2D()
    datapath = join("train-debug.csv")
    df = pd.read_csv(datapath)
    mapper.fit(df["formula"])
    
if __name__ == '__main__':
    freeze_support()
    main()

from elm2d.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.