Python 无法使用Selenium在Pycharm中运行基本Py程序

Python 无法使用Selenium在Pycharm中运行基本Py程序,python,selenium,pycharm,Python,Selenium,Pycharm,我对编码很陌生。尝试运行过去20天的以下基本行,并获得以下错误。请帮忙。已尝试安装并卸载python、selenium和pycharm。还是同一个问题:( 我的代码: from selenium import webdriver browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application') browser.get('https://www.google.com')

我对编码很陌生。尝试运行过去20天的以下基本行,并获得以下错误。请帮忙。已尝试安装并卸载python、selenium和pycharm。还是同一个问题:(

我的代码:

from selenium import webdriver
browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application')
browser.get('https://www.google.com')
browser.quit()
错误-

"C:\Python 3.7.6\python.exe" C:/Users/PycharmProjects/sel/sel1.py
Traceback (most recent call last):
  File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Python 3.7.6\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Python 3.7.6\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/PycharmProjects/sel/sel1.py", line 2, in <module>
    browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application')
  File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Application' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1
“C:\Python 3.7.6\Python.exe”C:/Users/PycharmProjects/sel/sel1.py
回溯(最近一次呼叫最后一次):
文件“C:\Python 3.7.6\lib\site packages\selenium\webdriver\common\service.py”,第76行,起始处
标准偏差=管道)
文件“C:\Python 3.7.6\lib\subprocess.py”,第800行,在_init中__
恢复信号,启动新会话)
文件“C:\Python 3.7.6\lib\subprocess.py”,第1207行,在_execute_child中
startupinfo)
PermissionError:[WinError 5]访问被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:/Users/PycharmProjects/sel/sel1.py”,第2行,在
浏览器=webdriver.Chrome(可执行文件\路径='C:\ProgramFiles(x86)\Google\Chrome\Application')
文件“C:\Python 3.7.6\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第73行,在\uuu init中__
self.service.start()
文件“C:\Python 3.7.6\lib\site packages\selenium\webdriver\common\service.py”,第88行,在开始处
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“应用程序”可执行文件可能具有错误的权限。请看https://sites.google.com/a/chromium.org/chromedriver/home
进程已完成,退出代码为1

提前谢谢

您的可执行路径存在严重问题。抛出的错误表明您的程序对chrome驱动程序的访问被阻止。将chrome驱动程序的位置更改为其他位置(桌面、用户目录等),并将代码中的可执行路径更改为放置chromedriver的新路径,您应该会没事的

您的可执行路径存在严重问题。抛出的错误表明您的程序对chrome驱动程序的访问被阻止。将chrome驱动程序的位置更改为其他位置(桌面、用户目录等),并将代码中的可执行路径更改为放置chromedriver的新路径,您应该会没事的

我希望您已下载chromedriver,并且您没有尝试将selenium与普通chrome浏览器一起使用。正确的先生,im使用正常的Chrome浏览器路径。所以我知道我需要下载chromedriver,然后在exec path right中提供该路径??可执行路径就是chrome驱动程序的路径。是的,是的。我希望你已经下载了chromedriver,并且你没有试图在普通的chrome浏览器中使用selenium。正确的先生,我使用的是普通的chrome浏览器路径。所以我知道我需要下载chromedriver,然后在exec path right中提供该路径??可执行路径就是chrome驱动程序的路径。所以是的,是的,我需要下载chromedriver,然后在exec path中提供路径,对吗?反斜杠是Python中的转义字符。所以你的道路不是你所期望的。在路径中使用双反斜杠或正斜杠。因此我需要下载chromedriver,然后在exec path中提供路径,对吗?反斜杠在Python中是转义字符。所以你的道路不是你所期望的。在路径中使用双反斜杠或正斜杠。