• [WinError 193] %1 不是有效的 Win32 应用程序


    python运行爬虫程序报错如下:

    原因

      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\twisted\internet\defer.py", line 1660, in _inlineCallbacks
        result = current_context.run(gen.send, result)
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\crawler.py", line 85, in crawl
        self.spider = self._create_spider(*args, **kwargs)
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\crawler.py", line 108, in _create_spider
        return self.spidercls.from_crawler(self, *args, **kwargs)
      File "E:\PowerfulCrawl\PowerfulCrawl\spiders\powerful_crawl.py", line 160, in from_crawler
        spider = super(PowerfulCrawlSpider, cls).from_crawler(crawler, *args, **kwargs)
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\spiders\__init__.py", line 50, in from_crawler
        spider = cls(*args, **kwargs)
      File "E:\PowerfulCrawl\PowerfulCrawl\spiders\powerful_crawl.py", line 135, in __init__
        self.driver = Chrome(chrome_options=self.option, executable_path=self.settings.get('CHROME_DRIVER_PATH'))
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
        self.service.start()
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
        self.process = subprocess.Popen(cmd, env=self.env,
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
        hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
      File "D:\Program Files (x86)\PyCharm Community Edition 2022.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 578, in new_CreateProcess
        return getattr(_subprocess, original_name)(app_name, patch_arg_str_win(cmd_line), *args)

    builtins.OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

    原因是

    self.driver = Chrome(chrome_options=self.option, executable_path=self.settings.get('CHROME_DRIVER_PATH'))这行代码引起的

    根本原因是settings.py中的

    CHROME_DRIVER_PATH = r'/PowerfulCrawl/PowerfulCrawl/driver/chromedriver'

    配置错误,改成chromedriver真实的地址就可以了。

  • 相关阅读:
    精益生产之MES制造执行系统
    shell——随机数(RANDOM)+ expect 自动应答
    Android AMS——进程优先级更新(十八)
    synchronized原理-字节码分析、对象内存结构、锁升级过程、Monitor
    【Proteus仿真】【51单片机】井盖安全检测装置设计
    传参base64时的+号变空格问题
    代码信息化:软件业“第二次工业革命”的契机
    Spring Boot+Vue+阿里云OOS实现图片上传
    PE文件(十一)移动导出表和重定位表
    算法的时间复杂度和空间复杂度
  • 原文地址:https://blog.csdn.net/heidyxlw/article/details/126384227