pyinstaller不使用lxml

时间:2016-08-07 22:34:25

标签: python lxml pyinstaller

我正在尝试使用pyinstaller创建一个exe但仍然遇到此错误

transparent

这些是由于导入声明

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Foo extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Menu fileMenu = new Menu("File");

        ChoiceBox<String> languageBox = new ChoiceBox<String>();
        languageBox.getItems().addAll("English", "Deutsch");

        Menu languageMenu = new Menu();
        languageMenu.setId("transparent");
        languageMenu.setGraphic(languageBox);

        MenuBar menuBar = new MenuBar();
        menuBar.getMenus().addAll(fileMenu, languageMenu);

        BorderPane root = new BorderPane();
        root.setTop(menuBar);

        Scene scene = new Scene(root);
        scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());

        stage.setScene(scene);
        stage.setTitle("MCVE");
        stage.setWidth(640);
        stage.setHeight(480);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

我正在使用lxml == 3.6.0

我为lxml.etree创建了像这样的

的钩子
Traceback (most recent call last):
File "runautojama.py", line 28, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "autogen\jama_lib.py", line 24, in <module>
from lxml import html as htmlLib
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\lxml\html\__init__.py", line 54, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 546, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: DLL load failed: A dynamic link library (DLL) initialization     routine failed.
Failed to execute script runautojama

和lxml.html的简单钩子

from lxml import etree
from lxml import html

它将etree.pyd和其他pyd复制到路径,但它似乎仍然无法工作,我仍然得到相同的错误。你能说出我可能做错了吗?

我的spec文件:

import os.path
import glob

from PyInstaller.compat import EXTENSION_SUFFIXES
from PyInstaller.utils.hooks import collect_submodules, get_module_file_attribute

hiddenimports = collect_submodules('lxml')

binaries = []
lxml_dir = os.path.dirname(get_module_file_attribute('lxml'))
for ext in EXTENSION_SUFFIXES:
    lxmlMods = glob.glob(os.path.join(lxml_dir, '*%s*' % ext))
    for f in lxmlMods:
        binaries.append((f, 'lxml'))

1 个答案:

答案 0 :(得分:0)

@WombatPM感谢您指出。使用开发版3.3.dev0+gd3e0cb4

解决问题