gpt4 book ai didi

python - 缺少模块 Pyinstaller

转载 作者:太空宇宙 更新时间:2023-11-03 14:06:44 28 4
gpt4 key购买 nike

我一直在尝试使用 pyinstaller 将 .py 转换为 .exe,正如您从标题中看到的那样.. .exe 文件无法正确执行.. 它说它找不到模块(numpy)。所以我做了一些研究,发现 pyinstaller 在查找模块时可能会遇到困难。Pyinstaller 网站:

pyi-makespec --paths=/path/to/thisdir\ --paths=/path/to/otherdir myscript.py

上面的代码将帮助 pyinstaller 找到它们。我的问题是:我的库在哪个目录中? (如numpy、pandas等)这会是不同的代码吗?或者我会将其添加到我的代码中吗?或者这会出现在“pyinstaller myscript.py”这一行中的某个地方???谢谢

最佳答案

我 99.9999% 确定 pyinstaller 已经有 numpy 的钩子(Hook)

只需在 myscript.py 顶部添加 import numpy

并运行pyinstaller --onefile myscript.py && .\dist\myscript.exe

但是要回答你的问题,请查看你的 python 文件夹的 site-packages 文件夹(输入 which python 来查找你的 python 版本)或 which pyinstaller 来查看你的 pyinstaller位置(它应该与 which python 相同,但位于脚本文件夹中)

它曾经位于C:\PythonX.Y\Lib\

在 3.X 中,它通常位于您的 AppData 文件夹中

关于python - 缺少模块 Pyinstaller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48835956/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com