[英]Problem with PyInstaller and local packages
My project is structured as follows:我的项目结构如下:
example3/
window/
__init__.py
__init__.py
__main__.py
setup.py
example.py
in the main file:在主文件中:
import sys
from PySide2.QtWidgets import QApplication
import window
def main():
app = QApplication(sys.argv)
main_window = window.Main()
main_window.show()
app.exec_()
if __name__ == '__main__':
main()
The build script example.py for PyInstaller: PyInstaller 的构建脚本 example.py:
from example3.__main__ import main
if __name__ == '__main__':
main()
How do I get PyInstaller to recognize my project's packages or the modules in them?如何让 PyInstaller 识别我的项目包或其中的模块? PyInstaller only sees the packages installed using pip. I had read something about hook files but didn't really understand how to do it.
PyInstaller 只看到使用 pip 安装的包。我读过一些关于挂钩文件的内容,但并不真正理解如何去做。
I created the executable with the command:我使用以下命令创建了可执行文件:
> pyinstaller example.py --onefile
When I try to run the application I get the error message:当我尝试运行该应用程序时,我收到错误消息:
> ./dist/example
Traceback (most recent call last):
File "example.py", line 3, in <module>
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "example3/__main__.py", line 7, in <module>
File "/tmp/embedded.xpuoquuw.zip/shibokensupport/__feature__.py", line 146, in _import
ModuleNotFoundError: No module named 'window'
[127129] Failed to execute script 'example' due to unhandled exception!
The problem could be solved by telling PyInstaller the search path for my project's modules and packages:这个问题可以通过告诉 PyInstaller 我项目的模块和包的搜索路径来解决:
pyinstaller --onefile example.py --paths ./example3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.