python3.4cx_冻结[winerror5]只在其他机器上使用Selenium

2024-04-23 17:33:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近开始开发cx_freeze并创建.exe文件供其他人使用。在

该脚本相当简单:它使用Selenium在网站上获取javascript敏感内容,并在用户发现匹配的href+将链接复制到剪贴板时向用户发出通知:

主代码在主.py公司名称:

from bs4 import BeautifulSoup
from selenium import webdriver
import time
import pyperclip

def check():
    browser.get(browser.current_url)
    page_html = browser.page_source.encode('utf8')
    soup = BeautifulSoup(page_html, "lxml")
    complete_list = soup.find_all('a', href=True)

    for a in complete_list:
        if LINK_TO_FIND in a['href']:
            pyperclip.copy(a['href'])
            while True:
                beep()

browser = webdriver.Chrome(executable_path=path_to_chromedriver)
browser.get(URL_TO_CHECK)

while True:

    check()
    time.sleep(5)

将代码冻结在设置.py公司名称:

^{pr2}$

直到昨天,这个脚本在我的和其他机器上都运行得很好。但从昨天开始,每当有人运行新构建的系统时,这个错误就开始出现。exe:s。(新版本对我来说还是不错的,旧版本在其他机器上仍然可以工作):

Traceback (most recent call last):
    File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\service.py", line 68, in start
    File "C:\Python34\lib\subprocess.py", line 859, in __init__
    File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occured:

Traceback (most recent call last):
    File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in (module)
    File "main.py", line 48, in (module)
    File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\service.py", line 80, in start
selenium.common.exceptions.WebDriverException: Message: 'exe.win32-3.4' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

我试过的一些事情:

  • 编译旧版本只是为了检查是否有问题 用密码。在
  • 执行python setup.py build时以管理员身份启动控制台
  • 禁用我的防病毒软件
  • 确保chromedriver.exe在正确的位置(如果不正确,将引发另一个错误)。在

Tags: inpyimportbrowserlibpackagesseleniumline
1条回答
网友
1楼 · 发布于 2024-04-23 17:33:43

好吧,经过大约4个小时的故障排除,我意识到在发送的版本的末尾,path_to_chromedriver丢失了{},但对于我在本地使用的版本来说是正确的。开枪打我。在

相关问题 更多 >