关于安装paddle 发行版本遇到protobuf 的报错问题

k10s72fa  于 2022-12-31  发布在  其他
关注(0)|答案(5)|浏览(1358)

问题描述 Please describe your issue

问题原因:
protobuf 于 2022.05.26 发布了 4.21 版本,如果您环境中没有 protobuf 的话,默认安装 paddle 时会自动下载最高版本的protobuf 4.21,paddle能安装成功但是 import paddle 会报错,这是由于protobuf 4.21 为不兼容升级,目前 develop 版本的 paddle 已经修复了这个问题( see #43009 ),但是发行版由于已经编包发布所以仍存在这个问题,飞桨会在下个版本2.3.1中解决。
参考:

解决办法:

手动降低 protobuf 为 3.x
pip install protobuf==3.20.1

完整报错:

(py39) C:\Users\Admin>hub install ge2e_fastspeech2_pwgan==1.0.0
Traceback (most recent call last):
File "f:\anaconda3\envs\py39\lib\runpy.py", line 197, in run_module_as_main
return run_code(code, main_globals, None,
File "f:\anaconda3\envs\py39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "f:\anaconda3\envs\py39\Scripts\hub.exe_main
.py", line 4, in
File "f:\anaconda3\envs\py39\lib\site-packages\paddlehub_init
.py", line 18, in
import paddle
File "f:\anaconda3\envs\py39\lib\site-packages\paddle_init.py", line 25, in
from .framework import monkey_patch_variable
File "f:\anaconda3\envs\py39\lib\site-packages\paddle\framework_init.py", line 17, in
from . import random # noqa: F401
File "f:\anaconda3\envs\py39\lib\site-packages\paddle\framework\random.py", line 16, in
import paddle.fluid as fluid
File "f:\anaconda3\envs\py39\lib\site-packages\paddle\fluid
init_.py", line 36, in
from . import framework
File "f:\anaconda3\envs\py39\lib\site-packages\paddle\fluid\framework.py", line 35, in
from .proto import framework_pb2
File "f:\anaconda3\envs\py39\lib\site-packages\paddle\fluid\proto\framework_pb2.py", line 33, in
_descriptor.EnumValueDescriptor(
File "f:\anaconda3\envs\py39\lib\site-packages\google\protobuf\descriptor.py", line 755, in new
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

zlwx9yxi

zlwx9yxi1#

protobuf 已经撤销了4.21 版本在pypi源上的发布( https://pypi.org/project/protobuf/4.21.0/ ) ,如果你使用pip install paddlepaddle 默认从pypi源下载依赖的话不会再遇到import paddle 报错,但是你从国内源下载(清华源、百度源等),则依然会下载protobuf 4.x,需要手动降低版本再使用paddle

wooyq4lh

wooyq4lh2#

我也遇到了这一问题,但是当我手动降低版本后会出现
requests.exceptions.SSLError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

wpx232ag

wpx232ag3#

如果你使用pip install paddlepaddle 默认从pypi源下载依赖的话不会再遇到import paddle 报错

yank 的第二天就发布了 4.21.1,所以还会有这个问题

另外,降级是有效的(如 3.20.1),不会出现其他问题

prdp8dxp

prdp8dxp4#

我也遇到了这一问题,但是当我手动降低版本后会出现
requests.exceptions.SSLError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

这问题与此无关吧,建议另开 issue 详述问题

相关问题