【问题标题】:PY2EXE and SELENIUM ISSUEPY2EXE 和硒问题
【发布时间】:2017-08-07 00:21:55
【问题描述】:

阅读了所有关于它的帖子后,我仍然不明白为什么我的 exe 不起作用.....

这是我的“setup.py”:

# -*- coding: cp1252 -*-
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')

wd_path = 'C:\\Python27\\Lib\\site-packages\\selenium\\webdriver'
required_data_files = [('selenium/webdriver/firefox',
                    ['{}\\firefox\\x86\\x_ignore_nofocus.so'.format(wd_path), '{}\\firefox\\amd64\\x_ignore_nofocus.so'.format(wd_path)]),('selenium/webdriver/remote',['{}\\remote\\getAttribute.js'.format(wd_path),'{}\\remote\\isDisplayed.js'.format(wd_path)])]

setup(
windows = [{'script': "autovote.py"}],
dll_excludes=['msvcr71.dll', "IPHLPAPI.DLL", "NSI.dll",  "WINNSI.DLL",  "WTSAPI32.dll"],
data_files = required_data_files,
name = "AutoVote 100% Naruto",
version="1.0",
description = "AutoVote 100% Naruto V1.0 réalisé par GARBEZ François contact:fgarbez-dev@netcourrier.com",
options = {
           "py2exe":{
                     "bundle_files": 1,
                     "compressed":1,
                    }
           }
)

这是错误日志:

Traceback (most recent call last):
File "autovote.py", line 4, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "selenium\webdriver\__init__.pyc", line 18, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "selenium\webdriver\firefox\webdriver.pyc", line 34, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "selenium\webdriver\remote\webdriver.pyc", line 25, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "selenium\webdriver\remote\webelement.pyc", line 40, in <module>
File "pkgutil.pyc", line 591, in get_data
IOError: [Errno 2] No such file or directory: 'selenium\\webdriver\\remote\\getAttribute.js'

但是我的所有文件都在我的 dist\selenium\webdriver 中...因为它是在编译时创建的...我也尝试过 PYInstaller,那个根本不起作用...我尝试了几乎所有我看到的东西在相同的主题上......没有什么可以解决它T.T

感谢您的帮助:)

【问题讨论】:

    标签: python selenium webdriver py2exe


    【解决方案1】:

    我重新制作了 setup.py :

    # -*- coding: cp1252 -*-
    from distutils.core import setup
    import py2exe, sys, os
    sys.argv.append('py2exe')
    
    wd_path = 'C:\\Python27\\Lib\\site-packages\\selenium\\webdriver'
    required_data_files = [('selenium/webdriver/firefox',
                        ['{}\\firefox\\x86\\x_ignore_nofocus.so'.format(wd_path), '{}\\firefox\\amd64\\x_ignore_nofocus.so'.format(wd_path)]),('selenium/webdriver/remote',['{}\\remote\\getAttribute.js'.format(wd_path),'{}\\remote\\isDisplayed.js'.format(wd_path)])]
    
    setup(
    windows = [{'script': "autovote.py"}],
    name = "AutoVote 100% Naruto",
    version="1.0",
    description = "AutoVote 100% Naruto V1.0 réalisé par GARBEZ François contact:fgarbez-dev@netcourrier.com",
    dll_excludes=['msvcr71.dll', "IPHLPAPI.DLL", "NSI.dll",  "WINNSI.DLL",  "WTSAPI32.dll"],
    data_files = required_data_files,
    options = {
               "py2exe":{ 
                         "skip_archive": True,
                        }
               }
    )
    

    唯一不同的是我起飞了:

    'zipfile':None,
    

    'bundle_files':1,
    

    现在它正在工作....好吧,我仍然不明白,但至少它可以工作:)

    【讨论】:

    • 有人能给我解释一下吗?
    猜你喜欢
    • 1970-01-01
    • 2011-03-23
    • 2011-07-15
    • 2010-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    相关资源
    最近更新 更多