在import tensorflow as tf 時(shí)報(bào)錯(cuò)no mould tensorflow,自然而然想到pip一下,但是pip一直顯示成功,并且不會報(bào)任何錯(cuò)
1.報(bào)錯(cuò):導(dǎo)入import tensorflow as tf時(shí),會出現(xiàn)cannot import name ‘Callable‘ from ‘typing_extensions‘。
由于我下載的是python3.7版本,tensorflow可能需要下載補(bǔ)丁包,故在網(wǎng)上查詢解決方案:
pip install typing_extensions
在下載后,將該目錄下的function_type.py中的
from typing import Any,Callable,Dict, Mapping, Optional, Sequence, Tuple
改為
from typing_extensions import Any,Callable,Dict, Mapping, Optional, Sequence, Tuple
此時(shí)依舊會報(bào)錯(cuò)cannot import name ‘Callable‘ from ‘typing_extensions‘
說明typing_extensions里面沒有Callable,而typing中沒有OrderedDict。
2.交叉組合一下把兩個(gè)包一起導(dǎo)入
只能選擇“各取所需”,組合一下試試
from typing import Any,Callable,Dict, Mapping, Optional, Sequence, Tuple
from typing_extensions import OrderedDict
這里前提是已經(jīng)pip install typing_extensions了,也就是兩個(gè):typing_extensions和typing都存在的情況下,改寫。文章來源:http://www.zghlxwxcb.cn/news/detail-560710.html
再次運(yùn)行tensorflow則不會報(bào)錯(cuò)
文章來源地址http://www.zghlxwxcb.cn/news/detail-560710.html
到了這里,關(guān)于【已解決cannot import name ‘OrderedDict‘ from ‘typing‘】的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!