[英]"Importing tensorflow module not found" Only on jupyter notebook but not jupyter lab or terminal
[英]when importing matplotlib in Jupyter Notebook no subpackages found
我正在嘗試在 Jupyter Notebook 中導入 matplotlib.pyplot (版本 3.2.1),但一直出錯。
值得一提的是,我的筆記本電腦上有 ArcGIS,其中有 Python 2.7 和 Matplotlib 版本 1,而不是 3。下面列出的步驟在 Z4149CE0EE30A909A1F62C583FF202 中工作正常。
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot
我嘗試通過運行 pip uninstall matplotlib 從命令行(使用 Windows)卸載整個東西,然后再安裝回來,但它似乎也沒有任何效果。
只需導入 matplotlib 就可以正常工作,直到我運行一些包含其功能的代碼。 然后出現錯誤,即
import matplotlib
此單元格運行沒有錯誤。 然后我嘗試展示一些基本的東西:
x = [0, 1, 2, 3, 4]
y = [2, 2, 2, 2, 2]
df = pd.DataFrame([x,y], columns=['a','b','c','d','f'])
df['b'].hist()
matplolib.pyplot.show()
並獲得多個回溯輸出
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in _get_plot_backend(backend)
1599 # Because matplotlib is an optional dependency and first-party backend,
1600 # we need to attempt an import here to raise an ImportError if needed.
-> 1601 import pandas.plotting._matplotlib as module
1602
1603 _backends["matplotlib"] = module
ModuleNotFoundError: No module named 'matplotlib.artist'
我也試過這個:
%matplotlib
import matplotlib.pyplot as plt
這導致了另一個錯誤:
~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in find_gui_and_backend(gui, gui_select)
286 # overwritten that.
287 # WARNING: this assumes matplotlib 1.1 or newer!!
--> 288 backend = matplotlib.rcParamsOrig['backend']
289 # In this case, we need to find what the appropriate gui selection call
290 # should be for IPython, so we can activate inputhook accordingly
AttributeError: module 'matplotlib' has no attribute 'rcParamsOrig'
請幫我解決這個問題。
嘗試如下重新安裝模塊。 損壞的安裝可能會導致此錯誤。
pip install --upgrade --force-reinstall matplotlib
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.