0

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.

Jörg Beyer
  • 3,631
  • 21
  • 35
fortyTwo102
  • 113
  • 1
  • 9

2 Answers2

0

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.

NL23codes
  • 1,181
  • 1
  • 14
  • 31
  • Thanks a lot for replying. I tried the method you mentioned above, and 1) The module in question exists in the /../site-packages directory and 2) I'm getting an ValueError when I'm trying to build the .exe the way you've mentioned. I think it's because the folders in my path have spaces in their names. But because of 1), I don't think finding the module is the issue. The module in question is a .pyd file, could it be that PyInstaller is having trouble with this file format? is there a way around to it? Again, thank you a lot for responding. – fortyTwo102 Feb 12 '19 at 14:49
  • So I understand fully, you modified your folder names to remove the spaces, which fixed the ValueError but the primary issue persists? Here's a suggestion - go to this link, check out the video and download this guy's py to exe program. It makes creating an exe from a .py file a breeze and may be able to solve your problem. https://www.youtube.com/watch?v=OZSZHmWSOeM I use this program on a regular basis to build my exe and it is very reliable. If you have questions on it, let me know or even message the developer through his youtube channel or on GitHub. He's actually fairly quick to respond. – NL23codes Feb 13 '19 at 15:45
  • Hey thanks again for replying! I solved the issue and have commented it here. The problem was that pyinstaller doesn't recognize .pyd external modules unless its explicitly mentioned in the .spec file, which I did and it worked! – fortyTwo102 Feb 14 '19 at 16:41
0

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.

fortyTwo102
  • 113
  • 1
  • 9