使用Pycharm和windows 7 Term的Pandas Profiling 1.4问题

2024-04-28 22:00:33 发布

您现在位置:Python中文网/ 问答频道 /正文

在pycharm或windows终端上执行Pandas分析时显示此错误

Pycharm latest
Python version 3.6 Windows 7 Pandas profiling 1.4

pandas_profiling.ProfileReport(df) :

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.

Tags: thetoyousupportpandasifmainnot
1条回答
网友
1楼 · 发布于 2024-04-28 22:00:33

所以这个问题的解决方法很简单,如下所示:

在我的代码中添加了一个main,然后在最后调用if name语句来运行。这很快就解决了我的问题。

import pandas as pd
import pandas_profiling
def main():
# my code for profiling
    df = pd.read_csv('csvfile')
    profile = pandas_profiling.ProfileReport(df)
    profile.to_file("profile.html")

if __name__ == "__main__": main()

相关问题 更多 >