经过几个小时尝试所有我能尝试的方法后,我在这里发布了这个问题。
我正在尝试运行这个使用 chromium 来执行的 python 脚本。
https://github.com/FallingLights/Teachable-dl
我已经全部安装好了,现在正尝试运行脚本并登录,但它一直说找不到 chromedriver.exe。
但是文件存在,我知道它在正确的位置,因为我将 Linux 版本粘贴到同一位置并将其重命名为 chromedriver.exe,它给出了有关运行 16 位程序的错误。我还从 google 存档中为 chromedriver.exe 添加了最新版本,当我运行脚本时,它说新版本与我当前的版本不兼容,所以我知道它确实在读取文件。
那么为什么它告诉我它不存在?
此外,我似乎无法在 cygwin 中安装 chromium。从 chromium-browser、chromium、chrome、chrome-browser 等所有东西都试过了,但都找不到。我使用了 cygwin 软件包安装程序 (setup),但即使我将下拉列表更改为全部,软件包安装程序列表中也找不到 chromium 或 chrome。
apt-cyg install chromium-browser
Installing chromium-browser
Unable to locate package chromium-browser
apt-cyg install chromium
Installing chromium
Unable to locate package chromium
但是,这是有效的:
$ pip show selenium
Name: selenium
Version: 4.16.0
Summary:
Home-page: https://www.selenium.dev
Author:
Author-email:
License: Apache 2.0
Location: /home/User/Teachable-Dl/env/lib/python3.9/site-packages
Requires: certifi, trio, trio-websocket, urllib3
Required-by: seleniumbase
无论如何,这是我尝试运行脚本时收到的错误:
User@User-PC ~/Teachable-Dl
$ python3 main.py --url https://courseurl.com/courses/enrolled/869509 --man_login_url https://sso.teachable.com/secure/1096/identity/login/password --verbose
Traceback (most recent call last):
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 2963, in get_local_driver
if os.path.exists(LOCAL_CHROMEDRIVER):
File "/usr/lib/python3.9/genericpath.py", line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/User/Teachable-Dl/main.py", line 789, in <module>
downloader = TeachableDownloader(verbose_arg=verbose, complete_lecture_arg=args.complete_lecture,
File "/home/User/Teachable-Dl/main.py", line 52, in __init__
self.driver = Driver(uc=True, headed=True)
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/seleniumbase/plugins/driver_manager.py", line 488, in Driver
driver = browser_launcher.get_driver(
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 1591, in get_driver
return get_local_driver(
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 3839, in get_local_driver
driver = webdriver.Chrome(service=service)
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
self.service.start()
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start
self._start_process(self._path)
File "/home/User/Teachable-Dl/env/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 208, in _start_process
self.process = subprocess.Popen(
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\.cache\\selenium\\chromedriver\\win64\\109.0.5414.74\\chromedriver.exe'
(env)
现在,如果我直接运行该路径:
cygstart "C:\\Users\\User\\.cache\\selenium\\chromedriver\\win64\\109.0.5414.74\\chromedriver.exe"
它运行起来和单击它一样,所以文件存在并且路径正确。弹出窗口是一个命令窗口,以“正在启动 ChromeDriver 109....”开头,最后一行是“ChromeDriver 已成功启动”
但是当我尝试运行该脚本时,同一个文件却显示不存在。
我还将 chromedriver.exe 文件粘贴到工作目录中的 /env/bin/ 文件夹中,但它仍然说不存在,但现在它说新正确路径上的文件不存在,换句话说,它在新位置检测并找到它,但仍然说它不存在,但它确实存在。
另外,如果我删除该路径上的文件夹,然后再次运行该脚本,它仍然会失败,但它也会在该路径上创建目录并将 chromedriver.exe 放在该目录中 - 这意味着它实际上将文件放在那里,但它说找不到它。
发生了什么事?我该如何解决这个问题?