How can I solve " module 'pandas' has no attribute 'scatter_matrix' " error?

Another option is keeping only pandas import and rewriting the command scatter_matrix, like in the example below:

import pandas as pd

pd.plotting.scatter_matrix(iris_df, alpha=0.2, figsize=(10, 10))

Using

from pandas.plotting._misc import scatter_matrix

don't use pd.scatter_matrix or pandas.scatter_matrix you can directly call scatter_matrix

e.g.

cmap = cm.get_cmap('gnuplot')
scatter = scatter_matrix(X, c = y, marker = 'o', s=40, hist_kwds={'bins':15}, 
    figsize=(9,9), cmap = cmap)
plt.suptitle('Scatter-matrix for each input variable')
plt.savefig('fruits_scatter_matrix')
plt.show()

This method is under pandas.plotting - docs and pandas.plotting.scatter_matrix:

from pandas.plotting import scatter_matrix

scatter_matrix(iris_df, alpha=0.2, figsize=(10, 10))