无法将python文件(包含selenium)转换为exe

无法将python文件(包含selenium)转换为exe,python,python-3.x,selenium,selenium-webdriver,Python,Python 3.x,Selenium,Selenium Webdriver,我正在尝试将python文件转换为exe文件。 我用过pyinstaller 我遵循的步骤: 我在脚本所在的文件夹中打开了cmd 我使用了下一个comand:pyinstaller--onefile-w name.py 当我想打开exe时,我得到了下面的错误。我想提到的是,我使用selenium来打开Mozilla Firefox浏览器。 创建可执行文件后,更新name.spec文件中的驱动程序路径并更新可执行文件。比如 1.binaries=[('path\chromedriver.exe

我正在尝试将python文件转换为exe文件。 我用过pyinstaller

我遵循的步骤:

  • 我在脚本所在的文件夹中打开了cmd
  • 我使用了下一个comand:pyinstaller--onefile-w name.py
当我想打开exe时,我得到了下面的错误。我想提到的是,我使用selenium来打开Mozilla Firefox浏览器。

创建可执行文件后,更新
name.spec
文件中的驱动程序路径并更新可执行文件。比如

1.binaries=[('path\chromedriver.exe', '.')]
2.pyinstaller name.spec
此外,请确保您已相应地更改了chrome路径

if getattr(sys, 'frozen', False):
  # executed as a bundled exe, the driver is in the extracted folder
  chromedriver_path = os.path.join(sys._MEIPASS, "chromedriver.exe")
  driver = webdriver.Chrome(chromedriver_path)

这将允许可执行文件从系统路径获取chrome驱动程序。

您的脚本
name.py
是否导入了任何内容?例如,selenium import webdriver的
是的,selenium import webdriver的第一行
中有一个文件,您正在使用
pyinstaller--onefile
处理需要多个文件的内容。我正在使用Mozila firefox。如果getattrt(..):..
在我的代码中,我是否必须添加
?无论如何,在运行可执行文件时,您必须检查系统路径中的驱动程序路径。