Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

vps mydriver初始化失败 #148

Open
chen1415 opened this issue Jun 22, 2021 · 1 comment
Open

vps mydriver初始化失败 #148

chen1415 opened this issue Jun 22, 2021 · 1 comment

Comments

@chen1415
Copy link

chen1415 commented Jun 22, 2021

系统版本,包含位数:Ubuntu 20.10 x64

python版本: Python 3.8.6

软件/源码版本: v20210605

浏览器、驱动版本


详细描述

答:
初始化失败 ChromeDriver跑不起来

全部报错

答:

============================================================
Mydriver初始化失败
============================================================
Traceback (most recent call last):
  File "pandalearning.py", line 74, in <module>
    driver_login = Mydriver(nohead=False)
  File "/root/china/TechXueXi/SourcePackages/pdlearn/mydriver.py", line 80, in __init__
    self.driver = self.webdriver.Chrome(chrome_options=self.options)
  File "/root/environments/xxqg_env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "/root/environments/xxqg_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/root/environments/xxqg_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/root/environments/xxqg_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/root/environments/xxqg_env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /snap/chromium/1646/usr/lib/chromium-browser/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

建议

答:

看了好几个大佬的issue 我改了一下源码变成这样

            if os.path.exists("./chrome/chromedriver.exe"):  # win
                self.driver = self.webdriver.Chrome(executable_path="./chrome/chromedriver.exe",
                                                    chrome_options=self.options)
            elif os.path.exists("./chromedriver"):  # linux
                self.driver = self.webdriver.Chrome(executable_path="./chromedriver",
                                                    chrome_options=self.options)
            elif os.path.exists("/usr/lib64/chromium-browser/chromedriver"):  # linux 包安装chromedriver
                self.driver = self.webdriver.Chrome(executable_path="/usr/lib64/chromium-browser/chromedriver",
                                                    chrome_options=self.options)
            elif os.path.exists("/usr/local/bin/chromedriver"):  # linux 包安装chromedriver
                self.driver = self.webdriver.Chrome(executable_path="/usr/local/bin/chromedriver",chrome_options=self.options)
            
            elif os.path.exists("/usr/lib/chromium-browser/chromedriver"):  # raspberry linux 包安装chromedriver
                self.driver = self.webdriver.Chrome(chrome_options=self.options)
                # self.driver = self.webdriver.Chrome(executable_path="/usr/lib/chromium-browser/chromedriver",chrome_options=self.option)
            else:
                self.driver = self.webdriver.Chrome(executable_path="./chrome/chromedriver.exe",chrome_options=self.options)

我想问是不是一定要图形化的界面? vps应该能跑起来的吧?

$PATH

/root/environments/xxqg_env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/bin/chromedriver
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@chen1415 and others