在 exe PyInstaller 中找不到文件
Can't find files in exe PyInstaller
我正在尝试制作一个 exe 文件,其中使用 phantomjs exe 和 chromedriver exe 文件,并将这些文件包含在我用 PyInstaller 制作的 python exe 中。我不确定问题是 PyInstaller 没有将 exe 添加到正在制作的单个 exe 中,还是它们在 exe 中使用它们的 python 文件中的位置不正确。
这是生成 python exe 的 bat 文件的代码:
pyinstaller --noconfirm --log-level=WARN ^
--onefile --nowindow ^
--add-data="chromedriver.exe;."^
--add-data="phantomjs.exe;." ^
Grade_Submitter.py
这是应该在主 exe 文件中获取 phantomjs exe 的代码
driver = webdriver.PhantomJS("/phantomjs.exe")
感谢您的帮助。我认为主要问题是访问 exe 中的文件,而我的程序没有在 exe 外部查找文件。但是,我不太确定如何让它从 exe 中检索文件。如果文件位于 exe 之外的同一个文件夹中,我的程序就可以运行,但我需要它才能让所有文件只使用一个文件而不是多个文件。
你们说得对,我没看够Bundling data files with PyInstaller。给定的解决方案之一对我有用。另外,我得到的权限错误只是我将 .exe 文件添加为数据文件而不是二进制文件。
我正在尝试制作一个 exe 文件,其中使用 phantomjs exe 和 chromedriver exe 文件,并将这些文件包含在我用 PyInstaller 制作的 python exe 中。我不确定问题是 PyInstaller 没有将 exe 添加到正在制作的单个 exe 中,还是它们在 exe 中使用它们的 python 文件中的位置不正确。
这是生成 python exe 的 bat 文件的代码:
pyinstaller --noconfirm --log-level=WARN ^
--onefile --nowindow ^
--add-data="chromedriver.exe;."^
--add-data="phantomjs.exe;." ^
Grade_Submitter.py
这是应该在主 exe 文件中获取 phantomjs exe 的代码
driver = webdriver.PhantomJS("/phantomjs.exe")
感谢您的帮助。我认为主要问题是访问 exe 中的文件,而我的程序没有在 exe 外部查找文件。但是,我不太确定如何让它从 exe 中检索文件。如果文件位于 exe 之外的同一个文件夹中,我的程序就可以运行,但我需要它才能让所有文件只使用一个文件而不是多个文件。
你们说得对,我没看够Bundling data files with PyInstaller。给定的解决方案之一对我有用。另外,我得到的权限错误只是我将 .exe 文件添加为数据文件而不是二进制文件。