ImportError with PyInstaller (using module pattern.de)

…衆ロ難τιáo~ 提交于 2019-12-13 16:17:55

问题


I’m using a module named pattern.de (http://www.clips.ua.ac.be/pages/pattern-de) 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?


回答1:


(For posterity)

I had a similar problem with 'pattern.en'. My problem was fixed when I told pyinstaller to import 'pattern.text'. 'en', 'de', etc are actually contained in that directory.



来源:https://stackoverflow.com/questions/35654513/importerror-with-pyinstaller-using-module-pattern-de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!