vendredi 26 février 2016

ImportError with PyInstaller (using module pattern.de)

I’m using a module named pattern.de (http://ift.tt/1l8DYGf) to implement a tool for text mining. To make it available for my colleagues I wanted to convert it into a standalone application. That for I’m using PyInstaller. When I run the final executable file I get the following ImportError

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: No module named pattern.de
test returned -1
LOADER: OK.
LOADER: Cleaning up Python interpreter.

To make it easier to find a solution I reduced my script to the crucial part:

from pattern.de import parse, split

This is what I entered to start PyInstaller:

pyinstaller --onedir --name=test --hiddenimport pattern.de --debug "C:\Users\BBlag\PycharmProjects\LDA\test.py"

As you can see I added pattern.de explicitly as hiddenimport. But while PyInstaller runs it shows me that it is not able to find the module:

108 INFO: Analyzing hidden import 'pattern.de'
1215 ERROR: Hidden import 'pattern.de' not found

I’m pretty new to programming so please excuse if this question is trivial. I have been wondering if it could be connected to the fact, that the module itself (when it is being downloaded and installed) is called simply ‘pattern’. ‘Pattern.de’ is used to import the german version of the package. That’s why I also tried to hiddenimport ‘pattern’. When I do so, I don’t receive the above mentioned error from PyInstaller (here it finds the right module), but when executing the final application I get the following similar error:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: No module named de
test returned -1
LOADER: OK.
LOADER: Cleaning up Python interpreter.

The application obviously is missing the ‘de part’ here. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire