微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pyinstaller打包报错AttributeError: 'NoneType' object has no attribute 'get_filename'

问题

可以直接运行脚本, 但是用pyinstaller打包会报错

环境

python 3.6.8

Faker 13.3.3

pip 21.3.1

pyinstaller 4.10

pyinstaller-hooks-contrib 2022.0

报错

Traceback (most recent call last):

File "<string>", line 2, in <module>

ModuleNotFoundError: No module named 'text_unidecode'

Traceback (most recent call last):

File "/root/ddcw_bench/venv/lib/python3.6/site-packages/PyInstaller/utils/hooks/__init__.py", line 366, in get_module_file_attribute

attr = loader.get_filename(package)

AttributeError: 'nonetype' object has no attribute 'get_filename'

解决办法

咋一看是loader没得get_filename, 但是你在这代码前加一个 print(dir(loader)), 会发现有get_filename....

其实上面还有个报错是 No module named 'text_unidecode'

所以只需要安装下text_unidecode就行

pip install text_unidecode

其实这个算小坑吧.....

原文地址:https://cloud.tencent.com/developer/article/1968509

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐