1

我是 pyinstaller 的新手,当我尝试使用我的应用程序导入文件时出现此错误(NotImplementedError: Can't perform this operation for unregistered loader type)。

完整的回溯是:

Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1702, in __call__
  File "BioRank.py", line 190, in load
  File "site-packages\pandas\core\frame.py", line 710, in style
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "C:\Users\tizma\Anaconda3\lib\site- 
packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\pandas\io\formats\style.py", line 50, in <module>
  File "site-packages\pandas\io\formats\style.py", line 111, in Styler
  File "site-packages\jinja2\environment.py", line 830, in get_template
  File "site-packages\jinja2\environment.py", line 804, in _load_template
  File "site-packages\jinja2\loaders.py", line 113, in load
  File "site-packages\jinja2\loaders.py", line 234, in get_source
  File "site-packages\pkg_resources\__init__.py", line 1396, in has_resource
  File "site-packages\pkg_resources\__init__.py", line 1449, in _has
NotImplementedError: Can't perform this operation for unregistered loader type

我做了一些研究,发现 pyinstaller 不支持 pkg_resources。有没有解决这个问题的方法?

4

2 回答 2

2

我使用pyinstaller遇到了这个问题。解决方案是编辑your-python-path\Lib\site-packages\pandas\io\formats\stytle:转到第120行并更改

template = env.**get_template**("html.tpl")

template = env.**from_string**("html.tpl")

然后再试一次。
我的问题是我使用了背景颜色,pd.Series("backgroud....)而 pyinstaller 没有构建它,所以在更改后它可以工作。

于 2019-06-06T09:45:30.603 回答
1

我遇到了与不包括 pkg_resources 的 pyinstaller 完全相同的问题。上面拉斐尔的回答为我解决了问题。比我发现的与此问题相关的其他解决方案要简单得多。我需要编辑 style.py 文件。该解决方案也不需要规范文件中的任何其他数据,这很方便。

小路:

your_path\venv\Lib\site-packages\pandas\io\formats\style.py

前:

template = env.get_template("html.tpl")

后:

template = env.from_string("html.tpl")
于 2021-05-27T22:48:25.017 回答