Im using ACRCloud to recognize an audio file, I've build a GUI using tkinter and I'm freezing the code as an .exe file using PyInstaller. However, I'm getting this error when I'm running the .exe file:

ModuleNotFoundError: No module named 'acrcloud_extr_tool'

If I run it directly from the script, there's no error and it runs fine. Some help, please? I'm just starting out.

2

There are 2 best solutions below

0
fortyTwo102 On BEST ANSWER

I solved it. Turns out due to it being a binary file (of .pyd extension), it had to be added explicitly in the .spec file (read the pyinstaller documentation). I did it and it ran like a charm.

3
NL23codes On

From my experience using pyinstaller, I need to add a parameter to the build command, so that pyinstaller knows where to look for modules. If you are building from a command prompt, the line may read something like this:

pyinstaller "yourFileName.py"  

However, you can add other commands to this that specify how the exe is built - whether it has a custom icon, is console based or the console is hidden, etc. Additionally, you can add a list of paths, telling pyinstaller where to look for your modules and that's done like this:

pyinstaller -p C:\theFolderWhereYourCustomModulesAreSaved:C:\Users\yourName\AppData\Local\Programs\Python\Python36-32\Lib\site-packages  "yourFileName.py"

Notice there are no quotation marks around these file paths AND that they are separated by a colon. The path to your Python site packages may be a bit different than mine, but I left in all the same path info with the exception of my username, so edit that as needed for your own machine. Also, the first 'fake' path I have shown in the example would be if you have written some of your own modules and are importing them into your project. For example, if your main project is saved in C:\myProject but you have modules you've written that are imported into your program like this:

import myCustomModule

and THOSE modules are saved in C:\myProject\myModules, then you would change that command to look like this:

pyinstaller -p C:\myProject\myModules:C:\Users\yourName\AppData\Local\Programs\Python\Python36-32\Lib\site-packages  "yourFileName.py"

Hopefully this solves your problem.