简体   繁体   English

我试图通过pyinstaller制作.exe文件时遇到此错误-“ ModuleNotFoundError:没有名为'acrcloud_extr_tool'的模块”

[英]I'm getting this error when I'm trying to make an .exe file through pyinstaller - “ModuleNotFoundError: No module named 'acrcloud_extr_tool'”

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. 我正在使用ACRCloud识别音频文件,我已经使用tkinter构建了GUI,并且正在使用PyInstaller将代码冻结为.exe文件。 However, I'm getting this error when I'm running the .exe file: 但是,在运行.exe文件时出现此错误:

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. 我才刚开始。

From my experience using pyinstaller, I need to add a parameter to the build command, so that pyinstaller knows where to look for modules. 根据我使用pyinstaller的经验,我需要在build命令中添加一个参数,以便pyinstaller知道在哪里查找模块。 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: 但是,您可以向此命令添加其他命令以指定exe的构建方式-它是否具有自定义图标,基于控制台还是隐藏于控制台等。此外,您可以添加路径列表,告诉pyinstaller在哪里查看为您的模块,这样做是这样的:

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. 您的Python网站包的路径可能与我的不同,但是除了用户名外,我保留了所有相同的路径信息,因此请根据自己的计算机进行编辑。 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: 例如,如果您的主项目保存在C:\\ myProject中,但是您已经编写了一些模块,这些模块将被导入到程序中,如下所示:

import myCustomModule

and THOSE modules are saved in C:\\myProject\\myModules, then you would change that command to look like this: 并且THOSE模块保存在C:\\ myProject \\ myModules中,那么您可以将该命令更改为如下所示:

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

Hopefully this solves your problem. 希望这可以解决您的问题。

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). 由于是二进制文件(扩展名为.pyd),因此必须将其显式添加到.spec文件中(请阅读pyinstaller文档)。 I did it and it ran like a charm. 我做到了,它像魅力一样运转。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我收到 ModuleNotFoundError: No module named '<anyproject> '</anyproject> - I'm getting ModuleNotFoundError: No module named '<anyproject>' 我收到ModuleNotFoundError:Ubuntu 18.04上没有名为_socket的模块 - I'm getting ModuleNotFoundError: No module named _socket on ubuntu 18.04 Pyinstaller,如何在尝试将 py 文件转换为 .exe 时解决“ModuleNotFoundError: No module named &#39;cogs&#39;”错误? - Pyinstaller,how to solve "ModuleNotFoundError: No module named 'cogs'" error while trying to convert py file to.exe? 当我使用 PyInstaller 将我的 gTTS 项目转换为 EXE 时出现错误 - I'm getting an error when I use PyInstaller to convert my gTTS project to an EXE 我得到 ModuleNotFoundError: No module named 'Cython' 尝试制作扩展时 - I got ModuleNotFoundError: No module named 'Cython' when trying to make Extension 收到错误 ModuleNotFoundError: No module named 'mysql' 当我安装它时 - getting error ModuleNotFoundError: No module named 'mysql' when i have installed it 我一直收到“ModuleNotFoundError:没有名为‘error’的模块” - I kept getting "ModuleNotFoundError: No module named 'error'" 我正在尝试通过 pyinstaller 将 .py 文件转换为 .exe 文件,但出现此警告 - I'm trying to convert a .py file into .exe file by pyinstaller but this warning showed up pyinstaller 无法使用 gspread 制作正确的 exe 文件。 ModuleNotFoundError:没有名为“gspread”的模块 - pyinstaller can't make correct exe file with gspread. ModuleNotFoundError: No module named 'gspread' exe 构建后的 Pyinstaller 错误:ModuleNotFoundError: No module named 'cmath' - Pyinstaller Error after exe built: ModuleNotFoundError: No module named 'cmath'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM