解决 PyInstaller 与 `pathlib` 包不兼容的问题

在使用 PyInstaller 打包 Python 程序时,可能会遇到类似如下的错误提示:

The 'pathlib' package is an obsolete backport of a standard library package and is incompatible with PyInstaller. Please remove this package (located in C:\Users\users\AppData\Local\Programs\Python\Python310\lib\site-packages) using
    "C:\Users\users\AppData\Local\Programs\Python\Python310\python.exe" -m pip uninstall pathlib
then try again.

这个错误的原因是,pathlib 这个包在 Python 3.4 版本之后已经成为了 Python 标准库的一部分,所以不需要再单独安装。而如果在安装了该包的环境中使用 PyInstaller,它会和 Python 标准库中的 pathlib 包发生冲突,导致 PyInstaller 无法正确工作。

解决方法

1. 卸载 pathlib

由于在 Python 3.10 中,pathlib 已经是标准库的一部分,我们不再需要额外安装它。因此,首先需要卸载已经安装的 pathlib 包。

在命令行中运行以下命令:

C:\Users\user
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值