pyinstaller 打包問題記錄


python 64位機器上 打包 32位 程序:

  • pyinstaller -F test/test.py 打包 好后 在winxp上運行不了,打包機器是64位的
  • 然后下載:anaconda: 下載32位的 python3.7 的版本,https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86.exe
  • 打包機器上的python是3.5版本的,安裝完32位的anaconda create 發現只有3.7,於是在打包電腦上環境執行: pip freeze>requirements.txt # 導出所有安裝的包
  • 然后在虛擬環境中導入:pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #導進包時怕版本不一致會有差別,所以把requirements.txt 后面的版本 "==3.1.0" 類似的全部去掉了
  • 然后在此虛擬環境中切到項目的主文件,pyinstaller -F test/test.py #報錯: ** maximum recursion depth exceeded ** #遞歸導致出錯
  • 接着修改生成的 test.spec 中第二行加上: #也可以把test.spec刪了,執行:pyi-makespec -F test/test.py 也會生成 test.spec,然后按照下面修改
import sys
sys.setrecursionlimit(50000)
  • 然后執行: pyinstaller -F test.spec #注意是 test.spec #之后打包成功,
  • 運行 報錯 : failed to execute script pyi_rth_win32comgenpy
  • 安裝pyqt5; pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5

打包出來的文件能不能使用需要在進行測試

  • 此時打出來的報經過測試在win7以上可以正常運行,但是xp系統會報錯:"無法定位程序輸入點 GetFinalPathNameByHandleW 於動態鏈接庫 KERNEL32.dll 上"
  • 然后查資料查到3.4以上就不支持xp系統,故需要在anacoda 上安裝python3.4
  • 然后在anacoda界面上根本沒有找到 python3.4
  • 然后在命令行: conda create -n py3.4forXp python=3.4 # 報錯"PackagesNotFoundError: The following packages are not available from current channels:"
  • 然后根據清華鏡像設置:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
  • 配置;可以通過修改用戶目錄下的 .condarc 文件: #Windows 用戶無法直接創建名為 .condarc 的文件,可先執行 conda config --set show_channel_urls yes 生成該文件之后再修改。
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  • 然后運行:conda create -n py3.4forXp python=3.4 #安裝成功
  • set CONDA_FORCE_32BIT=1是切換到32位 #需要在進入到conda 環境內輸入 =0 則是 64位, conda info 可以看到相關信息
  • conda info -e #可以看到新創建的環境py3.4forXp 已經創建成功
  • conda activate py3.4forXp #切到該環境
  • 安裝相關包:pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
  • requirements.txt里面有 numpy,pip 安裝python3.4沒有 numpy,所有在 requirements.txt 中把這個包刪了,
  • 然后執行: conda install numpy #自動安裝好了.然后繼續安裝其他的包,其他的也出現類似的情況也是這樣操作
  • 或者直接用conda安裝 requirements.txt
  • conda list -e > requirements.txt #導出包
  • conda install --yes --file requirements.txt #導入包
  • 實踐證明這個工具也有些安裝不了,還是先用上面的方法安裝


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM