Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 让py2exe在.zip中包含(Selenium).json文件_Python_Json_Selenium Webdriver_Py2exe - Fatal编程技术网

Python 让py2exe在.zip中包含(Selenium).json文件

Python 让py2exe在.zip中包含(Selenium).json文件,python,json,selenium-webdriver,py2exe,Python,Json,Selenium Webdriver,Py2exe,我花了一整天的时间试图解决py2exe问题,但没有将我所需的Selenium文件(webdriver.xpi和webdriver_pref.json)包含在我的.exe的library.zip或.exe中,这似乎是很多人以前遇到过的 我研究了许多类似的问题,并尝试对提供的答案进行修改,但没有结果(例如和)。我还了解到,在运行py2exe后手动传输文件不会像某些人建议的那样工作 我当前的setup.py看起来是这样的(尽管我有许多类似的变体,但都不起作用) 我总是会收到错误(在library.zi

我花了一整天的时间试图解决py2exe问题,但没有将我所需的Selenium文件(webdriver.xpi和webdriver_pref.json)包含在我的.exe的library.zip或.exe中,这似乎是很多人以前遇到过的

我研究了许多类似的问题,并尝试对提供的答案进行修改,但没有结果(例如和)。我还了解到,在运行py2exe后手动传输文件不会像某些人建议的那样工作

我当前的setup.py看起来是这样的(尽管我有许多类似的变体,但都不起作用)

我总是会收到错误(在library.zip或test.exe中,具体取决于捆绑包选项…)

有没有人找到一个简单的解决方案/解决办法来欺骗py2exe,包括.zip或.exe中的.xpi和.json文件?如果是,我将如何实施所需的更改

谢谢,
J

如何解压缩
库.zip
from distutils.core import setup
import py2exe

wd_base = 'C:\\Python34\\Lib\\site-packages\\selenium\\webdriver'
RequiredDataFiles = [
    ('selenium/webdriver/firefox', ['%s\\firefox\\webdriver.xpi'%(wd_base), '%s\\firefox\\webdriver_prefs.json'%(wd_base)])
]

setup(
    console=['test.py'],
    data_files=RequiredDataFiles,
    options={
            "py2exe":{
                "skip_archive": True,
                "unbuffered": True,
                "optimize": 2
            }
        }
)
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "test.py", line 177, in SellClick
  File "test.py", line 383, in seller
  File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 47, in __init__
    self.profile = FirefoxProfile()
  File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\firefox_profile
.py", line 63, in __init__
    WEBDRIVER_PREFERENCES)) as default_prefs:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\James\\OneDrive\\Python\\dist\\library.zip\\selenium\\webdriver\\firefox\\webdriver_prefs.json'