【发布时间】:2016-05-31 01:51:21
【问题描述】:
每当我导入 ftfy 并在我的 python 脚本应用程序中使用它时,我都没有任何问题。
如果我使用pyinstaller、cx_freeze 或py2exe 编译为二进制 exe,我的应用程序将毫无问题地编译,但每次运行应用程序时都会崩溃。
它崩溃的原因是它无法从chardata.py 中找到char_classes.dat 文件。
这是我在使用 pyinstaller 编译后运行我的应用程序并崩溃时得到的典型输出:
文件“C:\WinPy34\python-3.4.3.amd64\Lib\site-
包\PyInstaller\loader\pyimod03_importers.py",第 363 行,在 load_module exec(bytecode, module.dict)文件 "C:\WinPy34\python-3.4.3.amd64\Lib\site-packages\ftfy\chardata.py", 第 141 行,在 CHAR_CLASS_STRING = zlib.decompress(resource_string(名称, 'char_classes.dat')).decode('ascii')
文件 "C:\WinPy34\python-3.4.3.amd64\Lib\site-packages\pkg_resources__init__.p y",第 1173 行,在 resource_string self,resource_name
文件 "C:\WinPy34\python-3.4.3.amd64\Lib\site-packages\pkg_resources__init__.p y",第 1605 行,在 get_resource_string 中
返回 self._get(self._fn(self.module_path, resource_name))
文件 "C:\WinPy34\python-3.4.3.amd64\Lib\site-packages\pkg_resources__init__.p y",第 1683 行,在 _get 中 返回 self.loader.get_data(path) 文件 "C:\WinPy34\python-3.4.3.amd64\Lib\site-packages\PyInstaller\loader\pyimo d03_importers.py",第 445 行,在 get_data 中,open(path, 'rb') as fp:
FileNotFoundError: [Errno 2] 没有这样的文件或目录: 'C:\Users\BILLTH~1\Ap pData\Local\Temp\_MEI64282\ftfy\char_classes.dat'
d2e 返回 -1
此输出表明它无法找到 char_classes.dat 文件,即使该文件在 site-packages 目录中的 ftfy 模块中也存在 - 就像白天一样。
【问题讨论】:
-
我知道这是旧的,但想知道您是否找到了解决方案?
标签: python python-3.x pyinstaller py2exe cx-freeze