解決報(bào)錯“ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context'”

安裝的tensorflow版本和keras版本可能不合適的時候,會出現(xiàn)報(bào)錯

本文主要介紹Python中,使用tensorflow報(bào)錯:ImportError: cannot import name

'get_config' from 'tensorflow.python.eager.context'

(/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/eager/context.py)解決方法。

參考鏈接:https://www.cjavapy.com/article/2121/

解決方法1:

解決方法2:卸載重新安裝版本之后,不再出現(xiàn)報(bào)錯。

tf_gpu) C:\Users\dell>conda install tensorflow-gpu

Fetching package metadata ...............

Solving package specifications: .

Package plan for installation in environment D:\Users\dell\Anaconda3\envs\tf_gpu:

The following NEW packages will be INSTALLED:

? ? tensorflow:? ? 2.1.0-gpu_py36h3346743_0 defaults

? ? tensorflow-gpu: 2.1.0-h0d30ee6_0? ? ? ? defaults

Proceed ([y]/n)? y

(tf_gpu) C:\Users\dell>conda list -n tf_gpu

# packages in environment at D:\Users\dell\Anaconda3\envs\tf_gpu:

#

_tflow_select? ? ? ? ? ? 2.1.0? ? ? ? ? ? ? ? ? ? ? gpu? ? defaults

absl-py? ? ? ? ? ? ? ? ? 1.0.0? ? ? ? ? ? ? ? ? ? <pip>

absl-py? ? ? ? ? ? ? ? ? 0.15.0? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

aiohttp? ? ? ? ? ? ? ? ? 3.7.4.post0? ? ? py36h2bbff1b_2? ? defaults

astor? ? ? ? ? ? ? ? ? ? 0.8.1? ? ? ? ? ? py36haa95532_0? ? defaults

astor? ? ? ? ? ? ? ? ? ? 0.8.1? ? ? ? ? ? ? ? ? ? <pip>

astunparse? ? ? ? ? ? ? ? 1.6.3? ? ? ? ? ? ? ? ? ? <pip>

async-timeout? ? ? ? ? ? 3.0.1? ? ? ? ? ? py36haa95532_0? ? defaults

attrs? ? ? ? ? ? ? ? ? ? 21.2.0? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

blas? ? ? ? ? ? ? ? ? ? ? 1.0? ? ? ? ? ? ? ? ? ? ? ? mkl? ? defaults

blinker? ? ? ? ? ? ? ? ? 1.4? ? ? ? ? ? ? py36haa95532_0? ? defaults

brotlipy? ? ? ? ? ? ? ? ? 0.7.0? ? ? ? ? py36h2bbff1b_1003? ? defaults

ca-certificates? ? ? ? ? 2021.10.26? ? ? ? ? haa95532_2? ? defaults

cached-property? ? ? ? ? 1.5.2? ? ? ? ? ? ? ? ? ? <pip>

cachetools? ? ? ? ? ? ? ? 4.2.4? ? ? ? ? ? ? ? ? ? <pip>

cachetools? ? ? ? ? ? ? ? 4.2.2? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

certifi? ? ? ? ? ? ? ? ? 2021.10.8? ? ? ? ? ? ? ? <pip>

certifi? ? ? ? ? ? ? ? ? 2021.5.30? ? ? ? py36haa95532_0? ? defaults

cffi? ? ? ? ? ? ? ? ? ? ? 1.14.6? ? ? ? ? py36h2bbff1b_0? ? defaults

chardet? ? ? ? ? ? ? ? ? 4.0.0? ? ? ? ? py36haa95532_1003? ? defaults

charset-normalizer? ? ? ? 2.0.9? ? ? ? ? ? ? ? ? ? <pip>

charset-normalizer? ? ? ? 2.0.4? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

clang? ? ? ? ? ? ? ? ? ? 5.0? ? ? ? ? ? ? ? ? ? ? <pip>

click? ? ? ? ? ? ? ? ? ? 8.0.3? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

coverage? ? ? ? ? ? ? ? ? 5.5? ? ? ? ? ? ? py36h2bbff1b_2? ? defaults

cryptography? ? ? ? ? ? ? 3.4.7? ? ? ? ? ? py36h71e12ea_0? ? defaults

cudatoolkit? ? ? ? ? ? ? 10.1.243? ? ? ? ? ? h74a9793_0? ? defaults

cudnn? ? ? ? ? ? ? ? ? ? 7.6.5? ? ? ? ? ? ? ? cuda10.1_0? ? defaults

cython? ? ? ? ? ? ? ? ? ? 0.29.24? ? ? ? ? py36hd77b12b_0? ? defaults

dataclasses? ? ? ? ? ? ? 0.8? ? ? ? ? ? ? ? ? ? ? <pip>

flatbuffers? ? ? ? ? ? ? 1.12? ? ? ? ? ? ? ? ? ? ? <pip>

gast? ? ? ? ? ? ? ? ? ? ? 0.2.2? ? ? ? ? ? ? ? ? ? <pip>

gast? ? ? ? ? ? ? ? ? ? ? 0.4.0? ? ? ? ? ? ? ? ? ? <pip>

gast? ? ? ? ? ? ? ? ? ? ? 0.2.2? ? ? ? ? ? ? ? ? ? py36_0? ? defaults

google-auth? ? ? ? ? ? ? 1.33.0? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

google-auth? ? ? ? ? ? ? 1.35.0? ? ? ? ? ? ? ? ? ? <pip>

google-auth-oauthlib? ? ? 0.4.6? ? ? ? ? ? ? ? ? ? <pip>

google-auth-oauthlib? ? ? 0.4.4? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

google-pasta? ? ? ? ? ? ? 0.2.0? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

grpcio? ? ? ? ? ? ? ? ? ? 1.43.0? ? ? ? ? ? ? ? ? ? <pip>

grpcio? ? ? ? ? ? ? ? ? ? 1.36.1? ? ? ? ? py36hc60d5dd_1? ? defaults

h5py? ? ? ? ? ? ? ? ? ? ? 2.10.0? ? ? ? ? py36h5e291fa_0? ? defaults

h5py? ? ? ? ? ? ? ? ? ? ? 3.1.0? ? ? ? ? ? ? ? ? ? <pip>

hdf5? ? ? ? ? ? ? ? ? ? ? 1.10.4? ? ? ? ? ? ? h7ebc959_0? ? defaults

icc_rt? ? ? ? ? ? ? ? ? ? 2019.0.0? ? ? ? ? ? h0cc432a_1? ? defaults

idna? ? ? ? ? ? ? ? ? ? ? 3.3? ? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

idna_ssl? ? ? ? ? ? ? ? ? 1.1.0? ? ? ? ? ? py36haa95532_0? ? defaults

importlib-metadata? ? ? ? 4.8.1? ? ? ? ? ? py36haa95532_0? ? defaults

importlib-metadata? ? ? ? 4.8.3? ? ? ? ? ? ? ? ? ? <pip>

intel-openmp? ? ? ? ? ? ? 2021.4.0? ? ? ? ? haa95532_3556? ? defaults

keras? ? ? ? ? ? ? ? ? ? 2.6.0? ? ? ? ? ? ? ? ? ? <pip>

keras-applications? ? ? ? 1.0.8? ? ? ? ? ? ? ? ? ? ? py_1? ? defaults

keras-preprocessing? ? ? 1.1.2? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

libprotobuf? ? ? ? ? ? ? 3.17.2? ? ? ? ? ? ? h23ce68f_1? ? defaults

markdown? ? ? ? ? ? ? ? ? 3.3.4? ? ? ? ? ? py36haa95532_0? ? defaults

Markdown? ? ? ? ? ? ? ? ? 3.3.6? ? ? ? ? ? ? ? ? ? <pip>

mkl? ? ? ? ? ? ? ? ? ? ? 2020.2? ? ? ? ? ? ? ? ? ? ? 256? ? defaults

mkl-service? ? ? ? ? ? ? 2.3.0? ? ? ? ? ? py36h196d8e1_0? ? defaults

mkl_fft? ? ? ? ? ? ? ? ? 1.3.0? ? ? ? ? ? py36h46781fe_0? ? defaults

mkl_random? ? ? ? ? ? ? ? 1.1.1? ? ? ? ? ? py36h47e9c7a_0? ? defaults

multidict? ? ? ? ? ? ? ? 5.1.0? ? ? ? ? ? py36h2bbff1b_2? ? defaults

numpy? ? ? ? ? ? ? ? ? ? 1.19.5? ? ? ? ? ? ? ? ? ? <pip>

numpy? ? ? ? ? ? ? ? ? ? 1.19.2? ? ? ? ? py36hadc3359_0? ? defaults

numpy-base? ? ? ? ? ? ? ? 1.19.2? ? ? ? ? py36ha3acd2a_0? ? defaults

oauthlib? ? ? ? ? ? ? ? ? 3.1.1? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

openssl? ? ? ? ? ? ? ? ? 1.1.1l? ? ? ? ? ? ? h2bbff1b_0? ? defaults

opt_einsum? ? ? ? ? ? ? ? 3.3.0? ? ? ? ? ? ? pyhd3eb1b0_1? ? defaults

pip? ? ? ? ? ? ? ? ? ? ? 21.2.2? ? ? ? ? py36haa95532_0? ? defaults

protobuf? ? ? ? ? ? ? ? ? 3.19.1? ? ? ? ? ? ? ? ? ? <pip>

protobuf? ? ? ? ? ? ? ? ? 3.17.2? ? ? ? ? py36hd77b12b_0? ? defaults

pyasn1? ? ? ? ? ? ? ? ? ? 0.4.8? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

pyasn1-modules? ? ? ? ? ? 0.2.8? ? ? ? ? ? ? ? ? ? <pip>

pyasn1-modules? ? ? ? ? ? 0.2.8? ? ? ? ? ? ? ? ? ? ? py_0? ? defaults

pycparser? ? ? ? ? ? ? ? 2.21? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

pyjwt? ? ? ? ? ? ? ? ? ? 2.1.0? ? ? ? ? ? py36haa95532_0? ? defaults

pyopenssl? ? ? ? ? ? ? ? 21.0.0? ? ? ? ? ? pyhd3eb1b0_1? ? defaults

pyreadline? ? ? ? ? ? ? ? 2.1? ? ? ? ? ? ? ? ? ? ? py36_1? ? defaults

pysocks? ? ? ? ? ? ? ? ? 1.7.1? ? ? ? ? ? py36haa95532_0? ? defaults

python? ? ? ? ? ? ? ? ? ? 3.6.2? ? ? ? ? ? ? h09676a0_15? ? defaults

requests? ? ? ? ? ? ? ? ? 2.27.0? ? ? ? ? ? ? ? ? ? <pip>

requests? ? ? ? ? ? ? ? ? 2.26.0? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

requests-oauthlib? ? ? ? 1.3.0? ? ? ? ? ? ? ? ? ? ? py_0? ? defaults

rsa? ? ? ? ? ? ? ? ? ? ? 4.7.2? ? ? ? ? ? ? pyhd3eb1b0_1? ? defaults

rsa? ? ? ? ? ? ? ? ? ? ? 4.8? ? ? ? ? ? ? ? ? ? ? <pip>

scipy? ? ? ? ? ? ? ? ? ? 1.5.2? ? ? ? ? ? py36h9439919_0? ? defaults

setuptools? ? ? ? ? ? ? ? 58.0.4? ? ? ? ? py36haa95532_0? ? defaults

setuptools? ? ? ? ? ? ? ? 59.6.0? ? ? ? ? ? ? ? ? ? <pip>

six? ? ? ? ? ? ? ? ? ? ? 1.16.0? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

six? ? ? ? ? ? ? ? ? ? ? 1.15.0? ? ? ? ? ? ? ? ? ? <pip>

tensorboard? ? ? ? ? ? ? 2.0.2? ? ? ? ? ? ? ? ? ? <pip>

tensorboard? ? ? ? ? ? ? 2.6.0? ? ? ? ? ? ? ? ? ? <pip>

tensorboard? ? ? ? ? ? ? 2.4.0? ? ? ? ? ? ? pyhc547734_0? ? defaults

tensorboard-data-server? 0.6.1? ? ? ? ? ? ? ? ? ? <pip>

tensorboard-plugin-wit? ? 1.6.0? ? ? ? ? ? ? ? ? ? ? py_0? ? defaults

tensorboard-plugin-wit? ? 1.8.0? ? ? ? ? ? ? ? ? ? <pip>

tensorflow? ? ? ? ? ? ? ? 2.1.0? ? ? ? ? gpu_py36h3346743_0? ? defaults

tensorflow-base? ? ? ? ? 2.1.0? ? ? ? ? gpu_py36h55f5790_0? ? defaults

tensorflow-estimator? ? ? 2.0.1? ? ? ? ? ? ? ? ? ? <pip>

tensorflow-estimator? ? ? 2.6.0? ? ? ? ? ? ? pyh7b7c402_0? ? defaults

tensorflow-gpu? ? ? ? ? ? 2.1.0? ? ? ? ? ? ? ? h0d30ee6_0? ? defaults

termcolor? ? ? ? ? ? ? ? 1.1.0? ? ? ? ? ? ? ? ? ? <pip>

termcolor? ? ? ? ? ? ? ? 1.1.0? ? ? ? ? ? py36haa95532_1? ? defaults

typing-extensions? ? ? ? 3.10.0.2? ? ? ? ? ? hd3eb1b0_0? ? defaults

typing-extensions? ? ? ? 3.7.4.3? ? ? ? ? ? ? ? ? <pip>

typing_extensions? ? ? ? 3.10.0.2? ? ? ? ? pyh06a4308_0? ? defaults

typing_extensions? ? ? ? 4.0.1? ? ? ? ? ? ? ? ? ? <pip>

urllib3? ? ? ? ? ? ? ? ? 1.26.7? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

urllib3? ? ? ? ? ? ? ? ? 1.26.7? ? ? ? ? ? ? ? ? ? <pip>

vc? ? ? ? ? ? ? ? ? ? ? ? 14.2? ? ? ? ? ? ? ? h21ff451_1? ? defaults

vs2015_runtime? ? ? ? ? ? 14.27.29016? ? ? ? ? h5e58377_2? ? defaults

Werkzeug? ? ? ? ? ? ? ? ? 2.0.2? ? ? ? ? ? ? ? ? ? <pip>

werkzeug? ? ? ? ? ? ? ? ? 0.16.1? ? ? ? ? ? ? ? ? ? py_0? ? defaults

wheel? ? ? ? ? ? ? ? ? ? 0.37.0? ? ? ? ? ? pyhd3eb1b0_1? ? defaults

wheel? ? ? ? ? ? ? ? ? ? 0.37.1? ? ? ? ? ? ? ? ? ? <pip>

win_inet_pton? ? ? ? ? ? 1.1.0? ? ? ? ? ? py36haa95532_0? ? defaults

wincertstore? ? ? ? ? ? ? 0.2? ? ? ? ? ? ? py36h7fe50ca_0? ? defaults

wrapt? ? ? ? ? ? ? ? ? ? 1.12.1? ? ? ? ? py36he774522_1? ? defaults

wrapt? ? ? ? ? ? ? ? ? ? 1.13.3? ? ? ? ? ? ? ? ? ? <pip>

yarl? ? ? ? ? ? ? ? ? ? ? 1.6.3? ? ? ? ? ? py36h2bbff1b_0? ? defaults

zipp? ? ? ? ? ? ? ? ? ? ? 3.6.0? ? ? ? ? ? ? pyhd3eb1b0_0? ? defaults

zlib? ? ? ? ? ? ? ? ? ? ? 1.2.11? ? ? ? ? ? ? h8cc25b3_4? ? defaults

(tf_gpu) C:\Users\dell>python

Python 3.6.2 |Anaconda, Inc.| (default, Sep 30 2017, 11:52:29) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> impoer tensorflow

? File "<stdin>", line 1

? ? impoer tensorflow

? ? ? ? ? ? ? ? ? ? ^

SyntaxError: invalid syntax

>>> import tensorflow

>>> import keras

>>>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 227,533評論 6 531
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,055評論 3 414
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,365評論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,561評論 1 307
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,346評論 6 404
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 54,889評論 1 321
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 42,978評論 3 439
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,118評論 0 286
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,637評論 1 333
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,558評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,739評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,246評論 5 355
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 43,980評論 3 346
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,362評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,619評論 1 280
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,347評論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,702評論 2 370

推薦閱讀更多精彩內(nèi)容