51Testing软件测试论坛

标题: selenium打包成exe报错errno2 [打印本页]

作者: 测试积点老人    时间: 2022-1-11 10:21
标题: selenium打包成exe报错errno2
问题遇到的现象和发生背景

用pycharm写了一个简单的爬虫程序,使用的是selenium的代码。用pyinstaller打包成exe后报错,errno2

  1. # coding=utf-8
  2. from selenium import webdriver
  3. import time


  4. driver = webdriver.Chrome()
  5. driver.get('http://www.baidu.com')
  6. time.sleep(3)
复制代码

运行结果及报错内容

  1. Traceback (most recent call last):
  2.   File "se_pachong.py", line 2, in <module>
  3.     from selenium import webdriver
  4.   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  5.   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  6.   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  7.   File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  8.   File "selenium\webdriver\__init__.py", line 18, in <module>
  9.   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  10.   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  11.   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  12.   File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  13.   File "selenium\webdriver\firefox\webdriver.py", line 25, in <module>
  14.   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  15.   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  16.   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  17.   File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  18.   File "selenium\webdriver\remote\webdriver.py", line 42, in <module>
  19.   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  20.   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  21.   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  22.   File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  23.   File "selenium\webdriver\remote\switch_to.py", line 25, in <module>
  24.   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  25.   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  26.   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  27.   File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  28.   File "selenium\webdriver\remote\webelement.py", line 37, in <module>
  29.   File "pkgutil.py", line 639, in get_data
  30.   File "PyInstaller\loader\pyimod03_importers.py", line 325, in get_data
  31. FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\T480\\AppData\\Local\\Temp\\_MEI318082\\selenium\\webdriver\\remote\\getAttribute.js'
复制代码
我的解答思路和尝试过的方法

试过改文件运行路径,但是不行。

我想要达到的结果

成功运行exe文件



作者: qqq911    时间: 2022-1-12 10:31
检查下环境变量
作者: jingzizx    时间: 2022-1-12 17:39
缺东西?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2