python virtualenv打包_[Python]打包用pyinstaller和 virtualenv

本文介绍了如何使用pyinstaller进行项目打包,以及如何通过virtualenv创建干净的虚拟环境以减小打包后的执行文件体积。首先,安装了pyinstaller及其依赖,然后安装并使用virtualenv创建了一个名为env_win的虚拟环境。在虚拟环境中安装了项目的依赖,并使用pyinstaller的--noconsole和--onefile选项打包了一个没有命令行界面的单文件执行程序,同时指定了图标。
摘要由CSDN通过智能技术生成

pyinstaller用在平常完成專案進度做打包的動作,但是沒有注意到環境設訂的很容易打包些不必要的python函式庫,造成生成的執行檔體積過大,不必要的函式庫是其他專案所留下的,為了把自己正在執行進度的專案和其他專案所使用的函式作區隔,於是我需要另一個工具virtualenv,顧名思義是指在系統中生成另一個乾淨虛擬環境並安裝對應專案的函式庫再打包就好了。

https://pypi.org/project/pyinstaller/

pip3 install pyinstaller

安裝pyinstaller訊息

Collecting pyinstaller

Downloading pyinstaller-4.0.tar.gz (3.5 MB)

|████████████████████████████████| 3.5 MB 656 kB/s

Installing build dependencies ... done

Getting requirements to build wheel ... done

Preparing wheel metadata ... done

Collecting pyinstaller-hooks-contrib>=2020.6

Downloading pyinstaller_hooks_contrib-2020.9-py2.py3-none-any.whl (163 kB)

|████████████████████████████████| 163 kB 3.2 MB/s

Collecting pywin32-ctypes>=0.2.0; sys_platform == "win32"

Using cached pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB)

Collecting altgraph

Using cached altgraph-0.17-py2.py3-none-any.whl (21 kB)

Requirement already satisfied: setuptools in c:\python38\lib\site-packages (from pyinstaller) (47.1.0)

Collecting pefile>=2017.8.1; sys_platform == "win32"

Using cached pefile-2019.4.18.tar.gz (62 kB)

Collecting future

Using cached future-0.18.2.tar.gz (829 kB)

Using legacy setup.py install for pefile, since package 'wheel' is not installed.

Using legacy setup.py install for future, since package 'wheel' is not installed.

Building wheels for collected packages: pyinstaller

Building wheel for pyinstaller (PEP 517) ... done

Created wheel for pyinstaller: filename=pyinstaller-4.0-py3-none-any.whl size=2789243 sha256=956a2274a87878cfafa47bc860d3836b530e1ce23d6904c089c2d7cbedb446f4

Stored in directory: c:\users\wifipc\appdata\local\pip\cache\wheels\9b\28\8f\f51ae22c4391bbeb36c8fdc68203b0c094445b4db824a6ab7d

Successfully built pyinstaller

Installing collected packages: pyinsta

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值