2014-12-01 110 views
1

我試圖出口Python應用程序使用GUI &硒,使用 「py2exe」出口的Python與 「py2exe」,硒錯誤

setup.py exe文件:

from distutils.core import setup 
import py2exe 

data_files = [('selenium\\webdriver\\firefox', ['C:\Python34\Lib\site-packages\selenium-2.44.0-py3.4.egg\selenium\webdriver\\firefox\webdriver.xpi']), 
       ('selenium\\webdriver\\firefox', ['C:\Python34\Lib\site-packages\selenium-2.44.0-py3.4.egg\selenium\webdriver\\firefox\webdriver_prefs.json'])] 

setup(
    name='app', 
    version='1.0', 
    console = {'Main.py'}, requires=['easygui', 'selenium'], 
    data_files=data_files, 

) 

我得到一個錯誤 -
FileNotFoundError:[錯誤2]沒有這樣的文件或目錄:C:\ Python34 \ DIST \ lib中 rary.zip \硒\的webdriver \火狐\ webdriver_prefs.json'

我嘗試手動添加文件到拉鍊,沒有工作。
有什麼建議嗎?

回答

0

您需要配置MANIFEST.in file

A MANIFEST.in file can be added in a project to define the list of files to include in the distribution built by the sdist command.

例如,您可以包括所有.json文件到構建:

recursive-include *.json 

另見:

+0

我有一些麻煩理解這個,我有一個manifest.py,所以我可以輸入命令「recursive-include * .json」 ? – Bar 2014-12-01 22:58:07

+0

@ user2920421 MANIFEST.in文件有特殊含義,請研究文檔和答案鏈接中提到的,謝謝 – alecxe 2014-12-01 23:02:59

1

我遇到和解決了類似的問題:

  1. 複製webdriver.xpi和webdriver_prefs.json到你的EXE directoy。
  2. 修改C:\ Python27 \ LIB \站點包\硒\ webdriver的\火狐\ firefox_profile.py:

更改 「os.path.join(os.path.dirname(文件)」進入 - >「os.path.join(os.path.dirname(文件),'.. \ .. \ .. \ .. \'」,有兩個地方。