我使用pip命令下載安裝paddlepaddle庫,具體命令如下所示,采用清華鏡像源,這樣下載速度更快!
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple paddlepaddle
安裝完成后,我來在python文件中導(dǎo)入飛漿,輸出其版本號(hào),具體如下所示:
import paddle
print(paddle.__version__)
但是,PyCharm卻報(bào)錯(cuò),具體報(bào)錯(cuò)信息如下所示:
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).
其實(shí),仔細(xì)閱讀報(bào)錯(cuò)信息就會(huì)發(fā)現(xiàn),報(bào)錯(cuò)的主要原因是因?yàn)閜rotobuf的版本太高而導(dǎo)致編譯錯(cuò)誤,所以我們只需要按照編譯器提示的信息下載3.19.0對(duì)應(yīng)的版本即可解決問題。
在PyCharm終端輸入以下命令安裝3.19.0版本的protobuf即可解決問題,具體代碼如下所示:文章來源:http://www.zghlxwxcb.cn/news/detail-674650.html
pip install protobuf==3.19.0
下載完畢后即可正確輸出paddle的版本!文章來源地址http://www.zghlxwxcb.cn/news/detail-674650.html
到了這里,關(guān)于解決:TypeError: Descriptors cannot not be created directly的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!