0

I created a .exe from my code with pyinstaller. To do so, I simply opened cmd, cd'ed the location of the .py file, then typed "pyinstaller name.py". However, when I run the .exe it creates, it simply flashes a terminal window and then closes. The installer gave no warnings that I'm aware of. When running the .exe with CMD, it tells me "ModuleNotFoundError: No module named 'pydub'", so that might be where I need to start. How do I make sure the module "pydub" is included in the .exe package?

Below is what cmd prints when trying to open the .exe.

Traceback (most recent call last):
File "MP3Shredder.py", line 1, in <module>
ModuleNotFoundError: No module named 'pydub'
[5008] Failed to execute script 'MP3Shredder' due to unhandled exception!
  • As the error suggests, the module is not present, so pyinstaller didn't include it for some reason. Please [edit] your question and show us how you created the executable. Note: the error is clearly in the import phase, so the rest of the code is fundamentally useless. – musicamante Jul 27 '22 at 19:13
  • Thank you, I have changed my question to better reflect my problem! – Andrew Worley Jul 27 '22 at 19:37
  • If you're running a virtual env, you should ensure that you're installing and using pyinstaller for *that* environment, see [this related post](https://stackoverflow.com/q/57227191). Also refer to the [documentation](https://pyinstaller.org/en/stable/when-things-go-wrong.html) to inspect what the builder actually does and check all its output to see any reference to pydub (or warning messages). – musicamante Jul 27 '22 at 20:06
  • @musicamante, thank you! I figured this out about 10 minutes ago. I didn't realize Thonny was a "Virtual Environment". It works now that I used Thonny's terminal window to package the code. Thanks again! – Andrew Worley Jul 27 '22 at 20:25

0 Answers0