PyInstaller Build Error: ImportError: No Module Named
When using PyInstaller to build a Python script into an executable, it's possible to encounter the error "ImportError: No module named 'blah'". This issue commonly occurs when there are dynamic imports or dependencies not recognized by the spec file generated during the build process.
To address this error, there are two main approaches:
In your case, the error mentions "No module named mysql". To resolve this, you can either add an unused import of mysql or add the following line to the binpath field in the spec file:
binpath = ['/path/to/mysql/module']
It's important to note that the onefile option in PyInstaller merely combines all generated files into a single executable. It does not affect the dependencies that need to be included in the build.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3