问题
可以直接运行脚本, 但是用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
其实这个算小坑吧.....