最近在学计算机视觉相关的知识,想找个开源项目来实践一下,所以找到了百度的飞桨。以下是本人的踩坑记录,仅供参考。
- 安装Python的版本一定要在 3.6 ~ 3.9之间,刚开始我安装的就是3.10,所以有各种莫名其妙的错误。
`import paddle
print(paddle.version)``
时出现如下报错:
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:
Downgrade the protobuf package to 3.20.x or lower.
Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
解决方法如下:
1、卸载protobuf 已经安装的版本
pip uninstall protobuf
2、安装3.19.0版本
pip install protobuf==3.19.0
安装时又出现如下错误:
Could not find a version that satisfies the requirement protobuf==3.19.0的问题
我们经常通过pip安装东西时常常会出现ERROR: Could not find a version that satisfies the requirement xxx的问题。该问题常常会误导我们认为是下载的安装包之间存在冲突,因而花费大量的时间去配置各种各样的环境。
其实出现这个问题的原因是python国内网络不稳定,直接导致报错。因此我们常用镜像源来解决此问题。
解决方法如下:
pip install protobuf==3.19.0 -i http://pypi.douban.com/simple/
–trusted-host pypi.douban.com
#使用 pip 工具安装 matplotlib 和 numpy
pip3 install matplotlib numpy -i https://mirror.baidu.com/pypi/simple
安装时报错:
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool
解决方法如下:
pip --default-timeout=100 install matplotlib numpy -i
https://pypi.douban.com/simple
以上是我个人的踩坑记录,解决完之后就能下载训练集和测试集数据并成功,执行推理并打印结果了。