python安装不上pyinstaller_Python3.6安装pyinstaller

在尝试将.py文件打包成.exe时遇到困难。首先通过`python -m pip install PyWin32`安装依赖,接着从官网下载与Python版本匹配的pyinstaller并解压到Python目录下。然后在命令行执行`python setup.py install`进行安装。如果出现未注册错误,可以运行提供的注册代码。此过程旨在解决Python3.6中pyinstaller安装不成功的问题。
摘要由CSDN通过智能技术生成

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

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

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

python

3a70c2f605377e0149ffa0ffe446aa77.png

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

720d6a9664ec55837d9c415f46dab43c.png

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

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

8aabf34f450779cd37ec91163e63a717.png

复制这个路径到环境变量

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

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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值