把python程序转成.exe

Section1  安装

安装 pyInstaller


pip install pyinstaller

---------------------------------------------------------------------

安装过程各种曲折

1.先是直接命令行  pip install pyinstaller,然后命令行网络断开

2.无奈只能本地安装  下载pyinstaller ,解压后到相应目录 python setup.py install


Installed c:\users\superdy\appdata\local\programs\python\python36\lib\site-packages\pyinstaller-3.1.1-py3.6.egg
Processing dependencies for PyInstaller==3.1.1
Searching for pypiwin32
Reading https://pypi.python.org/simple/pypiwin32/
Download error on https://pypi.python.org/simple/pypiwin32/: timed out -- Some packages may not be found!
Couldn't find index page for 'pypiwin32' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: _ssl.c:733: The handshake operation timed out -- Some packages may not be found!
No local packages or working download links found for pypiwin32
error: Could not find suitable distribution for Requirement.parse('pypiwin32')


这次没有遇到太多阻碍,然后在最后一步,又卡住了


手动下载 pypiwin32 手动安装

然后再次pyinstaller 目录再次 python setup.py install 成功



总结下: 1.如果网络环境可以的话 python setup.py install

2.如果网络环境不行的话,手动下载,手动安装 python setup.py install



Section2   更新和使用

安装完成之后

pyinstaller -F printOne.py


File "C:\Users\superDy\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinstaller-3.1.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 1499, in _scan_bytecode_stores
    name = co.co_names[oparg]
IndexError: tuple index out of range


猜测是pyinstaller版本不是最新造成的

pip install -U pyinstaller

Successfully installed altgraph-0.14 future-0.16.0 macholib-1.8 pefile-2017.9.3 pyinstaller-3.3 setuptools-36.6.0


继续打包  pyinstaller -F printOne.py


Building EXE from out00-EXE.toc completed successfully.


生成的.exe 默认在dist文件夹下面


完成!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值