簡體   English   中英

mplot3d中沒有名為外部的模塊

[英]No module named externals in mplot3d

我正在嘗試使用帶有matplotlib的mpl_toolkits.mplot3d.Axes3D可視化3d圖

我正在將Matplot版本'2.1.0'和scikit-learn verison 0.19.0使用python 3。 當我運行代碼時,它會產生以下錯誤,

from matplotlib.externals import six
ImportError: No module named 'matplotlib.externals'

我試圖通過刪除現有的matplotlib並再次安裝來解決此問題,但沒有任何運氣。

我正在嘗試運行此代碼

import numpy as np
import mglearn
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
from mpl_toolkits.mplot3d import Axes3D, axes3d


X, y = make_blobs(centers=4, random_state=8)
y = y % 2

X_new = np.hstack([X, X[:, 1:] ** 2])

figure = plt.figure()
ax = Axes3D(figure, elev=-152, azim=-26)
# plot first all the points with y == 0, then all with y == 1
mask = y == 0
ax.scatter(X_new[mask, 0], X_new[mask, 1], X_new[mask, 2], c='b', cmap=mglearn.cm2, s=60)
ax.scatter(X_new[mask, 0], X_new[mask, 1], X_new[mask, 2], c='r', marker='^', cmap=mglearn.cm2, s=60)
ax.set_xlabel("feature0")
ax.set_ylabel("feature1")
ax.set_zlabel("feature1 ** 2")

plt.show()

Error log after installing sabron package
The minimum supported version is 2.4.6

  ver=ver, min_ver=_MIN_NUMEXPR_VERSION), UserWarning)
Traceback (most recent call last):
  File "/home/asif/ml-codes/matpolitlib-tutorials/example-two.py", line 5, in <module>
    from mpl_toolkits.mplot3d import Axes3D, axes3d
  File "/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/__init__.py", line 4, in <module>
    from matplotlib.externals import six
ImportError: No module named 'matplotlib.externals'

執行:

sudo apt-get remove python3-matplotlib

根據您的錯誤日志,這將刪除/usr/lib/python3/dist-packages/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM