可执行 Tkinter 加硒
Posted
技术标签:
【中文标题】可执行 Tkinter 加硒【英文标题】:Executeable Tkinter plus selenium 【发布时间】:2016-10-01 19:58:35 【问题描述】:嗯,我越来越难以做到这一点,我已经尝试过 Cx_freeze
但它显示了这一点:
这是设置:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = "packages": ["os"], "excludes": ["tkinter","schedule","selenium"]
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "Yad2AutoAd",
version = "0.1",
description = "Auto Jumper for Yad2 Advertises",
options = "build_exe": build_exe_options,
executables = [Executable("Yad2Ads.py", base=base)])
并使用 pyinstaller 显示:
Traceback (most recent call last):
File "site-packages\selenium\webdriver\common\service.py", line 64, in start
File "subprocess.py", line 859, in __init__
File "subprocess.py", line 1114, in _execute_child
FileNotFoundError: [WinError 2] \u200f\u200fלמערכת אין אפשרות לאתר את הקובץ שצוי
ן
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Yad2Adv.py", line 9, in <module>
File "site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __ini
t__
File "site-packages\selenium\webdriver\common\service.py", line 71, in start
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executabl
e needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chrome
driver/home
Failed to execute script Yad2Adv
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrom
e.service.Service object at 0x0000000002C3D668>>
Traceback (most recent call last):
File "site-packages\selenium\webdriver\common\service.py", line 163, in __del_
_
File "site-packages\selenium\webdriver\common\service.py", line 135, in stop
AttributeError: 'Service' object has no attribute 'process'
好吧,我认为这是同样的错误,我应该怎么做我试图将 selenium 文件夹插入到与 exe 文件相同的文件夹中。 我认为这篇文章非常详细,如果看起来很长,很抱歉。 只是想确保你们理解这个问题。 提前致谢! 附言 初始化 webdriver 的代码:
driver = webdriver.PhantomJS()
并且 PhantomJs.exe 与项目位于同一文件夹中。
【问题讨论】:
能分享一下初始化chromedriver的代码吗? @SaurabhGaur - 添加在问题的底部,谢谢 :) 【参考方案1】:在 Saurabh Gaur 告诉我如果我正在初始化网络驱动程序之后,再重新考虑并搜索它,那么你必须创建可执行路径 为你的 webdriver 例如:
phantomdriver = r"C:\Users\Bar\PycharmProjects\Yad2FinalFix\phantomjs.exe"
driver = webdriver.PhantomJS(executable_path=phantomdriver)
这解决了我的问题,谢谢Saurabh Gaur,你救了我很多次!
【讨论】:
以上是关于可执行 Tkinter 加硒的主要内容,如果未能解决你的问题,请参考以下文章
如何通过连接到 sqlite3 数据库来制作可执行的 python tkinter 文件
CX_freeze 可执行文件将不起作用。 _tkinter DLL 加载失败