Py2exe不会将webdriver_prefs.json复制到构建中 [英] Py2exe isn't copying webdriver_prefs.json into builds

查看:112
本文介绍了Py2exe不会将webdriver_prefs.json复制到构建中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用py2exe编译一个Python 2.7脚本,该脚本使用Selenium 2.39.0打开Firefox窗口并执行一些例程.过去,我能够毫无问题地编译代码.但是今天,从硒2.35更新到2.39之后,我遇到了麻烦.当我尝试运行由编译后的代码生成的.exe时,出现以下错误:

I'm using py2exe to compile a Python 2.7 script that uses Selenium 2.39.0 to open up Firefox windows and carry out some routines. In the past, I've been able to compile the code without any issue. Today though, after updating from Selenium 2.35 to 2.39, I'm running into trouble. When I try to run the .exe generated by the compiled code, I get the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "Tkinter.pyo", line 1410, in __call__
  File "literatureonlineapi2.5.5.py", line 321, in startapi
  File "selenium\webdriver\firefox\webdriver.pyo", line 43, in __init__
  File "selenium\webdriver\firefox\firefox_profile.pyo", line 58, in __init__
IOError: [Errno 2] No such file or directory: 'C:\\Text\\Professional\\Digital H
umanities\\Programming Languages\\Python\\Query Literature Online\\LION 1.0\\2.5
\\2.5.5\\dist\\.\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
Here we go!
Exception in Tkinter callback
Traceback (most recent call last):
  File "Tkinter.pyo", line 1410, in __call__
  File "literatureonlineapi2.5.5.py", line 321, in startapi
  File "selenium\webdriver\firefox\webdriver.pyo", line 43, in __init__
  File "selenium\webdriver\firefox\firefox_profile.pyo", line 58, in __init__
IOError: [Errno 2] No such file or directory: 'C:\\Text\\Professional\\Digital H
umanities\\Programming Languages\\Python\\Query Literature Online\\LION 1.0\\2.5
\\2.5.5\\dist\\.\\selenium\\webdriver\\firefox\\webdriver_prefs.json'

(运行未编译的代码时不会出现此错误.)

(This error does not appear when I run the uncompiled code.)

我遇到了一个Google代码页,相信较新版本的Selenium会因为缺少这个缺少的webdriver_prefs.json文件而遇到了麻烦,但这并没有帮助我解决问题.

I came across a google code page that led me to believe newer versions of Selenium have had trouble with this missing webdriver_prefs.json file, but that didn't help me sort out the problem.

有人知道我如何手动提供丢失的文件吗?我将感谢其他人可以提供的任何帮助.

Does anyone know how I might manually provide the missing file? I would be grateful for any help others can offer.

推荐答案

我找到了一个解决方案,并认为如果其他人遇到类似问题,我会予以发布.我发现丢失的webdriver_prefs.json文件藏在

I found a solution, and thought I would post it in case others have a similar problem. I found the missing webdriver_prefs.json file tucked away in

C:\ Python27 \ Lib \ site-packages \ selenium-2.39.0-py2.7.egg \ selenium \ webdriver \ firefox \

C:\Python27\Lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\firefox\

导航到该目录后,我抓取了webdriver_prefs.json文件和webdriver.xpi文件.然后,我将这两个文件都复制到

After I had navigated to that directory, I grabbed the webdriver_prefs.json file and the webdriver.xpi file. I then copied both of those files into

dist \ selenium \ webdriver \ firefox \

dist\selenium\webdriver\firefox\

由py2exe创建,并能够按预期运行编译后的代码.上帝保佑女王.

created by py2exe, and was able to run the compiled code as expected. God save the queen.

这篇关于Py2exe不会将webdriver_prefs.json复制到构建中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆