Python Selenium追踪(最近一次调用): [英] Python Selenium Traceback (most recent call last):

查看:48
本文介绍了Python Selenium追踪(最近一次调用):的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将selenium用于python web scraper,但是当我尝试运行该程序时,出现以下错误:

I'm trying to use selenium for a python web scraper but when I try to run the program I get the following error:

"/Applications/Python 3.8/IDLE.app/Contents/MacOS/Python" "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 52548 --file /Users/xxxx/git/python/python_crawler_example_01/naver_crawling.py
pydev debugger: process 3004 is connecting

Connected to pydev debugger (build 192.7142.56)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

这是我的错误代码:

from selenium import webdriver
from bs4 import BeautifulSoup as bs

import time
import os, sys

driver = webdriver.Chrome()

time.sleep(2)

driver.close()

我正在使用 macos &pycharm

https://i.stack.imgur.com/dJtFi.jpg

推荐答案

您应该放置网络驱动程序的路径

you should put the path of your webdriver

示例:(如果在同一目录中)

example:(if it is in the same directory)

driver = webdriver.Chrome(executable_path = "/chromedriver.exe")

这篇关于Python Selenium追踪(最近一次调用):的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆