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

raise RuntimeError in spawn.py #167

Open
mmuuyyii opened this issue Jan 12, 2024 · 1 comment
Open

raise RuntimeError in spawn.py #167

mmuuyyii opened this issue Jan 12, 2024 · 1 comment

Comments

@mmuuyyii
Copy link

Hi,
I'm trying to run example data in db5.0 with PyCharm and python 3.11.7 as the notebook guides:

import cellphonedb
import pandas as pd
import sys
import os

cpdb_file_path = 'cellphonedb.zip'
meta_file_path = 'test_meta.txt'
counts_file_path = 'test_counts.txt' # I also try h5ad
from cellphonedb.src.core.methods import cpdb_statistical_analysis_method
deconvoluted, means, pvalues, significant_means = cpdb_statistical_analysis_method.call(
cpdb_file_path = cpdb_file_path,
meta_file_path = meta_file_path,
counts_file_path = counts_file_path,
counts_data = 'ensembl',
output_path = "cpdb")

When I run the code, the program goes to endless loop.
When I debug the code, I get the error in "spawn.py":

def _check_not_importing_main():
if getattr(process.current_process(), '_inheriting', False):
raise RuntimeError('''
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

    To fix this issue, refer to the "Safe importing of main module"
    section in https://docs.python.org/3/library/multiprocessing.html
    ''')

Could you please teach me what should I do?
Thanks a million.

@datasome
Copy link
Collaborator

Hi mmuuyyii,

I suggest you run the statistical method in jupyter instead (following instructions in https://github.com/ventolab/CellphoneDB/blob/master/notebooks/T1_Method2.ipynb). However, if you prefer to play around with the code in PyCharm first I think you need to set threads=1 in cpdb_statistical_analysis_method.call(). That parameter defaults to 4 if not specified and this is I think what is causing your error. Please see https://stackoverflow.com/questions/74644040/pycharm-multiprocessing-error-what-can-i-do and https://youtrack.jetbrains.com/issue/PY-50116 for more information.

Hope that helps.

Best,

Robert.

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

2 participants