在用pyinstaller打包python编写好的程序时,遇到了一些问题,其中有一个是no module named 'pkg_resources.py2_warn’
pyinstaller no module named 'pkg_resources.py2_warn'解决方法
经过一些探索后,找到了解决方法:
1.先用pyinstaller -D(F) xxx.py生成一下(不一定能正常运行)
2.(关键)经过第一步之后,目录下有个.spec文件,用记事本打开,里面有个hiddenimports,在这条里面加上pkg_resources.py2_warn
pyinstaller no module named 'pkg_resources.py2_warn'解决方法
3.再次用pyinstaller,注意这时候输入的命令是pyinstaller -D(F) xxx.spec
4.经过步骤2就可以解决这个问题,若仍然提示no module named XXXXX ,则再次写入到hiddenimports
5.需要经过几次调试,建议先用-D处理没问题之后再-F。

经过网上查询还有另一种解决方法:
1.pip uninstaller setuptools
2.pip installer setuptools==44.0.0
(不过这种方法对setuptools进行降级处理,可能有些功能不能使用)

经过这两种方法,程序可以正常运行。

相关文章:

  • 2021-05-15
  • 2021-11-06
  • 2021-08-29
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-14
  • 2021-08-01
  • 2021-08-26
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案