简体   繁体   English

如何解决 ModuleNotFoundError:没有名为“pandas”的模块

[英]How to resolve ModuleNotFoundError: No module named 'pandas'

I have this script that I originally created in Jupyter Notebooks and I saved it later on as a.py file, then I used auto-py-to-exe to convert it to an exe file.我有这个最初在 Jupyter Notebooks 中创建的脚本,后来我将其保存为 .py 文件,然后我使用 auto-py-to-exe 将其转换为 exe 文件。 When it runs it gives me this error:当它运行时,它给了我这个错误:

ModuleNotFoundError: No module named 'pandas' [23712] Failed to execute script due to unhandled exception! ModuleNotFoundError:没有名为“pandas”的模块 [23712] 由于未处理的异常,无法执行脚本!

It's importing pandas in at the top of the script, and I had used pip install to install pandas, and I thought I had all of my python --path variables set correctly, but clearly something still isn't set right. It's importing pandas in at the top of the script, and I had used pip install to install pandas, and I thought I had all of my python --path variables set correctly, but clearly something still isn't set right. Is this an issue of looking at the wrong directory?这是查看错误目录的问题吗?

This is apparently a somewhat common issue with auto-py-to-exe .这显然是auto-py-to-exe的一个常见问题。 I'd suggest reading through this blog post by the author for solutions to this and many other issues.我建议阅读作者的这篇博客文章,以解决这个问题和许多其他问题。 If you skip to here , the suggested solution is as follows:如果你跳到这里,建议的解决方案如下:

ModuleNotFoundError: No module named x / ImportError: No module named x ModuleNotFoundError:没有名为 x 的模块 / ImportError:没有名为 x 的模块

This means a particular module ('x' in this case) was not added to the package.这意味着未将特定模块(在本例中为“x”)添加到 package。 I have seen this occur with packages in the pandas library and win32api;我已经看到 pandas 库和 win32api 中的包会发生这种情况; as long as you can identify the package (eg 'x'), then it is very easy to fix.只要你能识别出package(例如'x'),那么很容易修复。

To fix this in the UI, open the advanced tab and find the --hidden-import input.要在 UI 中解决此问题,请打开高级选项卡并找到--hidden-import输入。 Simply paste the module name into this input and then repackage.只需将模块名称粘贴到此输入中,然后重新打包。 If the original error is still appearing, you have done this incorrectly.如果仍然出现原始错误,则说明您操作不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM