Python 3パッケージexe

1680 ワード

cx_Freeze(推奨しない)cx_Freezeのサポートのみを使用して、python3exeにパッケージ化した例を次に示します.
パッケージするpythonファイルの下に、このsetup.pyファイルを新規作成します.
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from cx_Freeze import setup, Executable

base = None

executables = [
    Executable('    .py', base=base)
]

setup(
    name="TTyb",
    version="1.0",
    description="    ",
    executables=executables
)

次に、現在のコマンドラインで実行します.
python3 setup.py build

現在のディレクトリの下にbuildファイルが生成され、exeファイルが生成されます.
注意:cx_Freezeは依存ファイルを無視してパッケージ化され、すべての一般的な依存ファイルはsite-packgeからbuildファイルに手動でコピーされ、特に面倒です.
PyInstaller(推奨)
後のPyInstallerpython3パッケージをサポートし始めました.このパッケージは便利です.現在のコマンドラインの下にあります.
#    :pyinstaller -F    (   py)
#      :
#–icon=    
#-F      exe  
#-w     ,    
#-c      ,   
#-D       ,    exe           
#pyinstaller -h      

# cmd      (  :cd     (    ))     py     :
#       
pyinstaller -F shjys_rjjqk.py  
#       
pyinstaller -F -w shjys_rjjqk.py  
#  
pyinstaller -F shjys_rjjqk.py  --noconsole

パッケージされたexeファイルは、同ディレクトリのdistファイルのうち、依存ファイルがあればdistフォルダの下に置けばよい
パッケージにエラーが発生した場合:
for real_module_name, six_moduleAttributeError: 'str' object has no attribute 'items'

説明setuptoolsバージョンはだめです.このバージョンを直接更新すればいいです.
pip3 install -U setuptools

私のブログは間もなくテンセント雲+コミュニティに同期して、みんなを招待して一緒に入居します:https://cloud.tencent.com/developer/support-plan?invite_code=3qlzjs99fq4gg