我正在尝试让我的Selenium应用程序正常工作。它可以编译所有内容,但是当我打开应用程序时,它会显示以下内容:
C:\Python34\dist>browse.exe Traceback (most recent call last): File "browse.py", line 9, in <module> File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 43, in __init__ self.profile = FirefoxProfile() File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\firefox_profile .py", line 64, in __init__ WEBDRIVER_PREFERENCES)) as default_prefs: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Python34\\dist\\lib rary.zip\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
我正在使用py2exe进行捆绑,并使用Firefox作为我的浏览器驱动程序。
Setup.py:
from distutils.core import setup import py2exe setup( console=['browse.py'], options={ "py2exe":{ "skip_archive": True, "unbuffered": True, "optimize": 2 } } )
您必须从C:\ Python27 \ Lib \ site-packages \ selenium \ webdriver \ firefox手动将webdriver.xpi和webdriver_prefs.json复制到dist \ selenium \ webdriver \ firefox