我正试图让我的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作为我的浏览器驱动程序。
设置.py:
from distutils.core import setup
import py2exe

setup(
console=['browse.py'],
options={
        "py2exe":{
                "skip_archive": True,
                "unbuffered": True,
                "optimize": 2
        }
}
)

最佳答案

检查原始答案:
Python - Trouble in building executable
您必须手动将webdriver.xpi和webdriver_prefs.json从C:\Python27\Lib\site packages\selenium\webdriver\firefox复制到dist\selenium\webdriver\firefox

关于python - 编译的py2exe应用程序 Selenium 中缺少文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25653870/

10-15 11:02