python脚本运行问题

python脚本运行问题

疑问

同一个脚本,使用sublime text编译报错,使用geany工具又能正常执行,难道是sublime text不能调用selenium么?
代码段如下

# coding=utf-8

from selenium import webdriver

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(6)

driver.get("https://www.baidu.com")
try:
    driver.find_element_by_id("kw")
    print ('test pass: ID found')  
except Exception as e:
    print ("Exception found", format(e))
driver.implicitly_wait(6)

driver.quit()

使用sublime text编译报错如下

Traceback (most recent call last):
  File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 992, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "FirstScript2.py", line 5, in <module>
    driver = webdriver.Chrome()
  File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "G:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


***Repl Closed***

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Python脚本运行指的是通过Python解释器执行Python脚本文件的过程。 首先,要运行Python脚本,我们需要确保已经安装了Python解释器。Python官网提供了Python解释器的下载安装包,我们可以根据自己的操作系统下载合适的版本进行安装。 安装完成后,我们可以打开命令行终端或者使用Python的集成开发环境(IDE)来执行Python脚本。在命令行终端中,我们可以输入`python`命令来启动Python解释器,然后使用`python 脚本文件路径`的格式来运行脚本。 例如,我们有一个名为`hello.py`的Python脚本文件,位于`/Users/username/Documents`目录下,我们可以在命令行中输入以下命令来运行脚本: ``` python /Users/username/Documents/hello.py ``` 在执行脚本时,Python解释器会逐行解释和执行脚本文件中的代码。脚本可以包含各种类型的Python代码,例如变量定义、函数定义、流程控制语句等。 当脚本执行完毕后,解释器会将结果输出到命令行终端。如果脚本中有打印语句,会将相应的内容输出到终端。如果脚本中有其他处理逻辑,可能会输出计算结果或产生其他可视化效果。 总之,Python脚本运行是指使用Python解释器执行脚本文件的过程,通过命令行或者IDE启动Python解释器,并指定要运行脚本文件路径来执行脚本。执行过程中,解释器会逐行解释和执行脚本中的代码,并将结果输出到终端。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值