【发布时间】:2020-08-21 01:22:54
【问题描述】:
当我将 setup.py 作为脚本运行时,读取参数文件没有问题。 当我使用 pyinstaller 构建并运行与 .exe 相同的脚本时,我收到以下错误。
>setup.exe
Traceback (most recent call last):
File "setup.py", line 106, in <module>
param_file_info = paramsfx.extract_param_file_info(param_text)
File "app\paramsfx.py", line 64, in extract_param_file_info
s_n = re.search(rc_n, param_file_text)
File "c:\users\xxxxxx\appdata\local\programs\python\python37-32\lib\re.py", line 183, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
[21776] Failed to execute script setup
我已经阅读了其他帖子如何解决此错误,但是在更改代码(作为脚本可以正常工作)之前,我想看看是否有人对为什么它将参数以不同方式读取为 .exe 有任何想法.
【问题讨论】:
-
pyinstaller使用了哪些标志?TypeError: cannot use a string pattern on a bytes-like object在实际的 python 文件中似乎有一个错误 -
pyinstaller.exe --onefile setup.spec --hidden-import=sqlite3 --additional-hooks-dir="C:\Users\xxx\AppData\Local\Programs\Python\Python37- 32\Lib\site-packages\PyInstaller\hooks" .py 文件很好,因为当我在 Spyder 中运行 setup.py 时,它一切正常,没有错误。
-
对于遇到此问题的任何人。 Spyder 只是根据您的设置忽略错误。当你构建一个exe文件时,它会抛出一个异常。更改为“cp1252”编码解决了这个问题。
标签: python pyinstaller