python用pyinstaller生成exe時報錯 TypeError: an integer is required (got type bytes)
python用pyinstaller生成exe時報錯:
126 INFO: PyInstaller: 3.5
126 INFO: Python: 3.8.0
126 INFO: Platform: Windows-10-10.0.15063-SP0
128 INFO: wrote C:\report\ToExe\pywin32-217\pywin32-217\TestHandler.spec
130 INFO: UPX is not available.
133 INFO: Extending PYTHONPATH with paths
[‘C:\report\ToExe\pywin32-217\pywin32-217’,
‘C:\report\ToExe\pywin32-217\pywin32-217’]
133 INFO: checking Analysis
199 INFO: checking PYZ
199 INFO: Building PYZ because PYZ-00.toc is non existent
201 INFO: Building PYZ (ZlibArchive) C:\report\ToExe\pywin32-217\pywin32-217\build\TestHandler\PYZ-00.pyz
Traceback (most recent call last):
File “c:\python\python38-32\lib\runpy.py”, line 192, in run_module_as_main
return run_code(code, main_globals, None,
File “c:\python\python38-32\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File “C:\Python\Python38-32\Scripts\pyinstaller.exe_main.py”, line 7, in
File “c:\python\python38-32\lib\site-packages\PyInstaller_main.py”, line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File “c:\python\python38-32\lib\site-packages\PyInstaller_main.py”, line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py”, line 844, in main
build(specfile, kw.get(‘distpath’), kw.get(‘workpath’), kw.get(‘clean_build’))
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py”, line 791, in build
exec(code, spec_namespace)
File “C:\report\ToExe\pywin32-217\pywin32-217\TestHandler.spec”, line 18, in
pyz = PYZ(a.pure, a.zipped_data,
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\api.py”, line 98, in init
self.postinit()
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\datastruct.py”, line 158, in postinit
self.assemble()
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\api.py”, line 128, in assemble
self.code_dict = {
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\api.py”, line 129, in
key: strip_paths_in_code(code)
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”, line 652, in strip_paths_in_code
consts = tuple(
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”, line 653, in
strip_paths_in_code(const_co, new_filename)
File “c:\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”, line 660, in strip_paths_in_code
return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
解決辦法:報錯前的pyinstaller是用 pip install pyinstaller 來安裝的,改成用 pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz 再安裝一次
其它說明:如果電腦中同時存在多個版本的python可能會導致各種問題(比如 “failed to execute script xxx” 、“failed to create process”),如果不是特別熟悉使用python只是為了偶爾使用的話最好把以前安裝的多餘的python版本刪掉或全部刪掉重新安裝(到官網下載最新的安裝程式,網上說32位的相容性比較好),安裝步驟可參考:https://blog.csdn.net/weixin_40844416/article/details/80889165
後續補充(填坑):
用這種方法生成的exe在某些電腦上執行沒問題,但到了某些電腦上就報failed to execute script pyi_rth_multiprocessing 等錯誤,最後解決方法是重新安裝python3.5 + 用pip install pyinstaller來安裝解決
相關文章
- Pycharm:設定完Anaconda後報錯TypeError: an integer is required (got type bytes)PyCharmErrorUIGo
- Python報錯:TypeError: a bytes-like object is required, not ‘str‘PythonErrorObjectUI
- PyInstaller打包Python程式為exePython
- pyinstaller打包python成.exe檔案Python
- pyinstaller 生成 exe 的閃退問題解決方案
- TypeError: can‘t concat str to bytesError
- [python爬蟲] 招聘資訊定時系統 (二).呼叫pyinstaller包生成exe檔案Python爬蟲
- 執行時報錯RuntimeError: expected device cpu but got device cuda:0ErrordevGo
- yolov5 train報錯:TypeError: expected np.ndarray (got numpy.ndarray)YOLOAIErrorGo
- Python成功解決TypeError: __init__() missing 1 required positional argument: ‘comment‘PythonErrorUI
- npm報錯 TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string.Received undefineNPMError
- TypeError: only integer scalar arrays can be converted to a scalar indexErrorIndex
- "Got a packet bigger than 'max_allowed_packet' bytes"錯誤解決辦法Go
- 【Python3】TypeError: unhashable type: 'list' -Python字典裡面不能有列表PythonError
- 使用pyinstaller打包exe檔案教程
- Python PyInstaller 安裝方法 及簡單的編譯exePython編譯
- TypeError: Object of type ‘datetime‘ is not JSON serializableErrorObjectJSON
- 1.python報錯:TypeError: 'int' object is not subscriptablePythonErrorObject
- python pyinstaller打包的exe 反編譯問題記錄 破解加密Python編譯加密
- 使用 pyinstaller 打包 py 檔案成 exe 程式
- pytorch 踩坑,TypeError: expected seqence object with len>_0 or a single integer_typeerror: expected sequence object with len __ 0PyTorchErrorObject
- 解決MySQL資料匯入報錯Got a packet bigger than‘max_allowed_packet’bytesMySqlGo
- Mysql提示 “ Got a packet bigger than 'max_allowed_packet' bytes”MySqlGo
- 直接用 appium 可以連線真機,用 pycharm 執行指令碼時報錯 “'platformVersion' must be of type string”APPPyCharm指令碼Platform
- python2 反編譯pyinstaller打包的可執行exe檔案Python編譯
- TypeError:a.replaceisnotafunction錯誤ErrorFunction
- 生成隨機字串應該用random_bytes還是openssl_random_pseudo_bytes隨機字串random
- 解決 TypeError: Type aliases cannot be used with isinstance(). 辦法Error
- java 反射 報錯:Attempt to get java.lang.Integer field "..." with illegal data type conversion to intJava反射
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- python pyinstaller庫Python
- Android Studio 中使用switch語句時報錯Constant expression required的解決方法AndroidExpressUI
- python3使用pyinstaller打包apscheduler出的錯Python
- Node.js 中 TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]Node.jsErrorImport
- Expected mime type application/octet-stream but got text/html.APPGoHTML
- SAP MRKO Error - For document type RE, an entry is required in field Reference -ErrorUI
- pyinstaller打包exe--requests模組打包後無法執行
- js報錯:TypeError: Date is not a constructorJSErrorStruct