python:使用PyInstaller打包成exe文件,以及TypeError: an integer is required (got type bytes)异常解决
本文主要介紹安裝pyinstaller教程與pyinstaller打包出現?TypeError: an integer is required (got type bytes)異常問題解決辦法:
1.安裝PyInstaller
執行:
pip install?PyInstaller?
如果遇到warning提示:
WARNING: You are using pip version 19.3.1; however, version 21.1.3 is available.You should consider upgrading via the 'python -m pip install --upgrade pip' command.就按照提示執行即可:
python -m pip install --upgrade pip執行完上述指令后,再輸入pip install?PyInstaller確認下
安裝完畢~~
2. 常用的PyInstaller打包命令參數如下:
–i 圖標路徑;
-F 打包成一個exe文件;
-w 無控制臺窗口;
-c 使用控制臺;
-D 創建一個目錄,里面包含exe以及其他一些依賴性文件;
一般看幫助即可,-h
3.打包py文件
首先寫一個demo:test.py
import?ospath?=??os.getcwd()print(f'current?path?is:{path}')os.system('pause')執行打包指令:
PyInstaller -F test.py執行成功后會生成build、dist文件夾如下所示:
其中exe程序就在dist中,驗證一下:
大功告成!
4.針對有些童鞋執行打包結果出現異常問題:TypeError: an integer is required (got type bytes)
解決方案:請輸入如下命令:
?pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz就完美解決TypeError: an integer is required (got type bytes)異常,使用PyInstaller打包完成。
5.友情提示:
如果電腦中同時存在多個版本的python可能會導致各種異常問題,建議只保留一個版本的python使用,最好安裝前,先完全刪除老的,然后再安裝新的,防止不必要麻煩。
6.引經據典:
http://www.pyinstaller.org/downloads.html
https://pyinstaller.readthedocs.io/en/stable/usage.html#general-options
總結
以上是生活随笔為你收集整理的python:使用PyInstaller打包成exe文件,以及TypeError: an integer is required (got type bytes)异常解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一道网易面试题
- 下一篇: 【不会吧不会吧,不会有人真的三分钟入门P