首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pandas-使用cx_Freeze分析问题

pandas-使用cx_Freeze分析问题
EN

Stack Overflow用户
提问于 2018-12-17 19:31:13
回答 1查看 288关注 0票数 0

我正在使用cx_freeze将我的Python应用程序转换为Windows可执行文件。我在我的一个脚本中使用了pandas-profiling包。当我运行我的exe文件时,我得到以下错误:

代码语言:javascript
复制
    File "C:\Users\Ronnie\python3.6\Lib\site-packages\pandas_profiling\__init__.py", line 10, in <module>
    import pandas_profiling.templates as templates
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\pandas_profiling\templates.py", line 64, in <module>
    row_templates_dict = {'NUM': template('row_num'),
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\pandas_profiling\templates.py", line 60, in template
    return jinja2_env.get_template(templates[template_name], globals=globals)
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\jinja2\environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\jinja2\environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\jinja2\loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\jinja2\loaders.py", line 234, in get_source
    if not self.provider.has_resource(p):
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\pkg_resources\__init__.py", line 1396, in has_resource
    return self._has(self._fn(self.module_path, resource_name))
  File "C:\Users\Ronnie\python3.6\Lib\site-packages\pkg_resources\__init__.py", line 1449, in _has
    "Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type

如果我将pandas-profiling放在与exe文件相同的目录中,然后运行它,我会得到以下错误:

代码语言:javascript
复制
 error: unrecognized arguments: --multiprocessing-fork 1448

在寻找多进程错误的解决方案时,我发现pandas-profiling在它的一个脚本中使用了multiprocessing,并且在该模块中需要有multiprocessing.freeze_support()调用,但我不知道将其添加到哪里。

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2018-12-17 20:34:15

引用multiprocessing.freeze_support()documentation

One需要直接在主模块的if __name__ == '__main__'行之后调用此函数。例如:

从多进程导入进程中,打印定义f():freeze_support (‘hello world!')如果进程‘__name__’:freeze_support() == (target=f).start()

因此,您需要在使用pandas-profiling的脚本的if __name__ == '__main__'行之后直接调用此函数。

如果脚本中没有这样的行:在脚本的第一个顶层代码行之前添加此行,并缩进整个脚本顶层代码,使其属于if块。请参阅What does if __name__ == "__main__": do?

另请参阅Python multiprocessing throws error with argparse and pyinstallerwhere to put freeze_support() in a Python script?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53814351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档