Home > database >  How to resolve ModuleNotFoundError: No module named 'pandas'
How to resolve ModuleNotFoundError: No module named 'pandas'

Time:08-11

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. When it runs it gives me this error:

ModuleNotFoundError: No module named 'pandas' [23712] Failed to execute script due to unhandled exception!

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?

CodePudding user response:

This is apparently a somewhat common issue with 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

This means a particular module ('x' in this case) was not added to the package. I have seen this occur with packages in the pandas library and win32api; as long as you can identify the package (e.g. 'x'), then it is very easy to fix.

To fix this in the UI, open the advanced tab and find the --hidden-import input. Simply paste the module name into this input and then repackage. If the original error is still appearing, you have done this incorrectly.

  • Related