pyinstaller打包报错:expected str, bytes or os.PathLike object, not NoneType

针对在Win10环境下使用PyCharm和pyinstaller3.4将Python项目打包为exe时出现TypeError的问题,本文提供了解决方案。通过修改bindepend.py文件中的特定代码段,能够成功避免NoneType错误,实现项目的顺利打包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

修复pyinstaller打包报错

环境:win10,PyCharm 2019.1.1 x64 ,phthon3.7,pyinstaller3.4
想使用pyinstaller打包发布成exe,报错
TypeError: expected str, bytes or os.PathLike object, not NoneType
解决方法是找到项目根目录下\venv\Lib\site-packages\PyInstaller\depend\bindepend.py这个文件打开修改,
搜索“Applies only to non Windows platforms”,在后面添加
if is_win and ‘VERSION.dll’ in dlls:
pydll = ‘python%d%d.dll’ % sys.version_info[:2]
if pydll in PYDYLIB_NAMES:
filename = getfullnameof(pydll)
return filename

插入代码后如下图
修改后如图
嫌麻烦的同学可以点这里下载替换bindepend.py

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值