Mac 下打包python 程序

  1. 先安装 pip 原文链接
    curl https://bootstrap.pypa.io/get-pip.py | python3,再用pip --version看是否安装成功
  2. 再安装 pip3 install py2app
  3. 使用py2applet创建setup文件 py2applet --make-setup XXX.py
  4. 发布程序:python3 setup.py py2app

如果报错,多为版本问题。
查看官网 python3.9 的 changelog,发现 HTMLParser.unescape 属性被移除了,并且从 python3.4 开始就被弃用。

1

pycharm 创建虚拟环境时,会使用到 setuptools。而 setuptools 中,刚好使用了这个属性,所以,导致了"AttributeError: "HTMLParser" object has no attribute "unescape""异常。

解决办法,卸载

pip uninstall setuptools 再安装高版本的pip install setuptools==49.2.1或更高版本pip install setuptools==50.3.2

原文链接

安装py2app时出现了没有权限的报错,WARNING: The directory ‘/Users/USERNAME/Library/Caches/pip‘ or its parent directory is not owned
使用该命令执行sudo -H pip3 install py2app即可

mac环境下打包出windows exe执行文件

exe

posted @ 2021-05-03 15:55  lambertlt  阅读(401)  评论(0编辑  收藏  举报