zoukankan      html  css  js  c++  java
  • PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\video\AppData\Local\Temp\tmpfipzk8ma'--问题解决

    学习python+selenium总是遇到各种问题

    代码如下:

    from selenium import webdriver
    browser = webdriver.PhantomJS() #浏览器初始化;Win下需要设置phantomjs路径,linux下置空即可
    url = 'http://www.zhidaow.com' # 设置访问路径
    browser.get(url) # 打开网页
    title = browser.find_elements_by_xpath('//h2') # 用xpath获取元素

    for t in title: # 遍历输出
    print(t.text) # 输出其中文本
    print(t.get_attribute('class')) # 输出属性值

    browser.quit()
    运行后报错:

      File "C:UsersvideoAppDataRoamingPythonPython34site-packagesseleniumwebdrivercommonservice.py", line 151, in __del__
      File "C:UsersvideoAppDataRoamingPythonPython34site-packagesseleniumwebdrivercommonservice.py", line 127, in stop
      File "C:UsersvideoAppDataRoamingPythonPython34site-packagesseleniumwebdriverphantomjsservice.py", line 68, in send_remote_shutdown_command
    PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\video\AppData\Local\Temp\tmpfipzk8ma'

    解决办法:(我是用pycharm)

    编辑C:UsersvideoAppDataRoamingPythonPython34site-packagesseleniumwebdriverphantomjsservice.py的文件

    找到:

    def send_remote_shutdown_command(self):
    if self._cookie_temp_file:
    os.remove(self._cookie_temp_file)
    修改如下:
    def send_remote_shutdown_command(self):

    try:
        if self._cookie_temp_file:
          os.remove(self._cookie_temp_file)
    except:
        pass

  • 相关阅读:
    任意数字 保留 两位 小数 PHP
    在JavaScript中处理JSON数据 jquery js 定义 json 格式
    相对定位 绝对定位 relative absolute position 图片定位a标签
    oracle: listener.ora 、sqlnet.ora 、tnsnames.ora的配置及例子
    python
    python
    python-判断alter是否存在
    python-IE浏览器调用
    Python语言编写脚本时,对日期控件的处理方式
    python报错UnicodeDecodeError:
  • 原文地址:https://www.cnblogs.com/huangweiping/p/5397204.html
Copyright © 2011-2022 走看看