Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 5: undying error when I run multiprocess code in Jupyter #26

Open
DemonsHunter opened this issue Feb 20, 2021 · 2 comments
Open

Comments

@DemonsHunter
Copy link

When I copy code in List 5.1 and run in jupyter, it always tells me this:

Can't get attribute 'square' on <module 'main' (built-in)>

According to what I have found in Google, it seems that the code needs to be titled:

if name =='main':

but this way only works in Spyder and Pycharm.

So I wanna know how you guys tackle it.

Grateful to hear any suggestions!

@DEUCE1957
Copy link

Had the same issue, this is because multiprocessing does not work natively inside a Jupyter notebook. For details see this StackOverflow discussion (specifically Eden Trainor's answer):
https://stackoverflow.com/questions/48846085/python-multiprocessing-within-jupyter-notebook

Apparently someone has created a similar library to multiprocessing called multiprocess which works inside jupyter notebooks. However, I suggest the authors (@azai91) either put a !pip install multiprocess in the notebook for this, or add a comment saying to run it from an IDE like Spyder. Since the multiprocess library has its own problems (had to re-import numpy inside the process) probably would go for the latter option.

@Summer-Canvas
Copy link

thanks for the link you provide
solved my question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants