py2exe打包的时候报错protobuf/pkg_resources找不到

在使用py2exe打包项目时遇到错误,提示protobuf和pkg_resources模块未找到。尝试将protobuf的egg文件解压后再打包,但运行时依旧报pkg_resources缺失。

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

问题:py2exe打包的时候报错protobuf/pkg_resources找不到

执行过程出了问题,提示说protobuf等几个模块找不到,

方法一:

1.于是找到Lib/site-packages/下的protobuf的安装包,egg文件(其实就是个zip压缩文件)

2. 使用7z本地解压,再打包,无出错提示,运行,失败,提示缺少pkg_resources模块

Traceback (most recent call last):
  ile "tolerance.py", line 11, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "TolerSeverMessage_pb2.pyo", line 4, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "google\__init__.pyo", line 1, in <module>
ImportError: No module named pkg_resources
发现是google文件夹下的__init__.py文件包含了__import__('pkg_resources').declare_namespace(__name__)
去掉即可,重新做包,运行OK。

方法二:
1.安装protocbuf的时候,使用python setup.py install_lib,这样的话\sripts\site-packages\下面就不是一个egg文件,而是解压后的文件,进入\google\protobuf下面
2.找到google文件夹下的__init__.py文件,去掉__import__('pkg_resources').declare_namespace(__name__),重新做包
-f https://download.pytorch.org/whl/cu113/torch_stable.html -f https://data.dgl.ai/wheels/repo.html anyio==3.5.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 async-generator==1.10 attrs==21.4.0 Babel==2.9.1 backcall==0.2.0 bleach==4.1.0 cached-property==1.5.2 cairocffi==1.2.0 CairoSVG==2.5.2 certifi==2021.10.8 cffi==1.15.0 chainer==7.8.1 chainer-chemistry==0.7.1 charset-normalizer==2.0.11 contextvars==2.4 cssselect2==0.4.1 cycler==0.11.0 decorator==4.4.2 defusedxml==0.7.1 dgl-cu113==0.8.0 dglgo==0.0.1 einops==0.4.0 entrypoints==0.4 filelock==3.4.1 googledrivedownloader==0.4 h5py==3.1.0 idna==3.3 imageio==2.15.0 immutables==0.16 importlib-metadata==4.8.3 ipykernel==5.5.6 ipython==7.16.3 ipython-genutils==0.2.0 isodate==0.6.1 jedi==0.17.2 Jinja2==3.0.3 joblib==1.1.0 json5==0.9.6 jsonschema==3.2.0 jupyter-client==7.1.2 jupyter-core==4.9.1 jupyter-server==1.13.1 jupyterlab==3.2.8 jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 kiwisolver==1.3.1 MarkupSafe==2.0.1 matplotlib==3.3.4 mistune==0.8.4 nbclassic==0.3.5 nbclient==0.5.9 nbconvert==6.0.7 nbformat==5.1.3 nest-asyncio==1.5.4 networkx==2.5.1 notebook==6.4.8 numpy==1.19.5 opencv-python==4.5.5.62 packaging==21.3 pandas==1.1.5 pandocfilters==1.5.0 parso==0.7.1 pbr==5.8.1 pexpect==4.8.0 pickleshare==0.7.5 Pillow==8.4.0 pkg_resources==0.0.0 prometheus-client==0.13.1 prompt-toolkit==3.0.26 protobuf==3.19.4 psutil==5.9.0 ptyprocess==0.7.0 pycparser==2.21 Pygments==2.11.2 pyparsing==3.0.7 pyrsistent==0.18.0 pysmiles==1.0.1 python-dateutil==2.8.2 pytz==2021.3 PyWavelets==1.1.1 PyYAML==6.0 pyzmq==22.3.0 rdflib==5.0.0 rdkit-pypi==2021.9.4 requests==2.27.1 scikit-image==0.17.2 scikit-learn==0.24.2 scipy==1.5.4 seaborn==0.11.2 Send2Trash==1.8.0 six==1.16.0 sklearn==0.0 sniffio==1.2.0 terminado==0.12.1 testpath==0.5.0 threadpoolctl==3.1.0 tifffile==2020.9.3 tinycss2==1.1.1 torch==1.10.2+cu113 tornado==6.1 tqdm==4.62.3 traitlets==4.3.3 typing==3.7.4.3 typing_extensions==4.0.1 urllib3==1.26.8 wcwidth==0.2.5 有哪些包需要我手动安装
03-19
root@JFPC1:~/Workspace/protobuf-21.12# make -j$(nproc) make all-recursive make[1]: Entering directory '/root/Workspace/protobuf-21.12' Making all in . make[2]: Entering directory '/root/Workspace/protobuf-21.12' make[2]: Leaving directory '/root/Workspace/protobuf-21.12' Making all in src make[2]: Entering directory '/root/Workspace/protobuf-21.12/src' CXX google/protobuf/wire_format.lo CXX google/protobuf/wrappers.pb.lo CXX google/protobuf/compiler/command_line_interface.lo CXX google/protobuf/compiler/code_generator.lo CXX google/protobuf/compiler/plugin.lo CXX google/protobuf/compiler/plugin.pb.lo CXX google/protobuf/compiler/subprocess.lo CXX google/protobuf/compiler/zip_writer.lo CXX google/protobuf/any_lite.lo CXX google/protobuf/compiler/main.o CXX google/protobuf/arenastring.lo CXX google/protobuf/arena.lo CXX google/protobuf/arenaz_sampler.lo CXX google/protobuf/extension_set.lo CXX google/protobuf/generated_enum_util.lo CXX google/protobuf/generated_message_tctable_lite.lo CXX google/protobuf/generated_message_util.lo CXX google/protobuf/implicit_weak_message.lo CXX google/protobuf/inlined_string_field.lo CXX google/protobuf/io/coded_stream.lo CXX google/protobuf/io/io_win32.lo CXX google/protobuf/io/strtod.lo CXX google/protobuf/io/zero_copy_stream.lo CXX google/protobuf/io/zero_copy_stream_impl.lo CXX google/protobuf/io/zero_copy_stream_impl_lite.lo CXX google/protobuf/map.lo CXX google/protobuf/message_lite.lo CXX google/protobuf/parse_context.lo CXX google/protobuf/repeated_field.lo CXX google/protobuf/repeated_ptr_field.lo CXX google/protobuf/stubs/bytestream.lo CXX google/protobuf/stubs/common.lo CXX google/protobuf/stubs/int128.lo CXX google/protobuf/stubs/status.lo CXX google/protobuf/stubs/statusor.lo 这里报
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值