zoukankan      html  css  js  c++  java
  • Python3.6安装pyinstaller

    很久之前装了python可是最近需要把xxx.py打包成xxx.exe,然后找了教程试了也无果,各种失败

    首先在cmd下输入:python -m pip install PyWin32

    然后在官网下载pyinstaller,下载前先看自己的python是32bit还是64bit:

    python

    在官网下载对应版本,解压,重命名(根据个人爱好)然后移动到python目录下:

    打开cmd,进入刚刚复制的文件夹的目录,执行:python setup.py install

    然后进入pyinstaller-pyinstaller文件夹下的script文件夹:

    复制这个路径到环境变量

    如果过程中出现未注册的提示信息复制以下代码运行后在安装

    import sys
    
    from winreg import *
    
    # tweak as necessary
    version = sys.version[:3]
    installpath = sys.prefix
    
    regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
    installkey = "InstallPath"
    pythonkey = "PythonPath"
    pythonpath = "%s;%s\Lib\;%s\DLLs\" % (
        installpath, installpath, installpath
    )
    
    
    def RegisterPy():
        try:
            reg = OpenKey(HKEY_CURRENT_USER, regpath)
        except EnvironmentError as e:
            try:
                reg = CreateKey(HKEY_CURRENT_USER, regpath)
                SetValue(reg, installkey, REG_SZ, installpath)
                SetValue(reg, pythonkey, REG_SZ, pythonpath)
                CloseKey(reg)
            except:
                print("*** Unable to register!")
                return
            print("--- Python", version, "is now registered!")
            return
        if (QueryValue(reg, installkey) == installpath and
                    QueryValue(reg, pythonkey) == pythonpath):
            CloseKey(reg)
            print("=== Python", version, "is already registered!")
            return
        CloseKey(reg)
        print("*** Unable to register!")
        print("*** You probably have another Python installation!")
    
    
    if __name__ == "__main__":
        RegisterPy()
  • 相关阅读:
    4.C#的选择语句练习
    3.C#中的选择语句
    java包静态导入,继承
    新的学期要继续学习喽
    桌球小游戏
    JAVA和C语言的区别
    BIV+CSS网页的标准化布局
    层叠样式表
    学PHP也要懂得HTML
    web开发入门
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13302380.html
Copyright © 2011-2022 走看看