2017-03-22 6 views
0

ich derzeit spyder bin mit 3.6 auf Windows 8 OS und wenn ich diesen Code ausführen es zeigt einen FehlerWie pydotplus in spyder importieren 3.6

Datei "", Zeile 12, in Import pydotplus

ModuleNotFoundError: Kein Modul namens 'pydotplus'

Hier ist der Code

import pydotplus 
dot_data = tree.export_graphviz(clf, out_file=None) 

graph = pydotplus.graph_from_dot_data(dot_data) 

graph.write_pdf("iris.pdf") 

from IPython.display import Image 
dot_data = tree.export_graphviz(clf, out_file=None,feature_names=iris.feature_names, 

class_names=iris.target_names, 

filled=True, rounded=True, 

special_characters=True) 

graph = pydotplus.graph_from_dot_data(dot_data) 

Image(graph.create_png()) 
+0

Nun, dann sollten Sie das Modul zunächst _installieren_. – ForceBru

+0

Aber können Sie mir bitte sagen, wie Sie es installieren? Ich finde keine Dokumentationen im Internet. Können Sie mir bitte helfen? – Saradamani

+0

haben Sie versucht, auf Stack Overflow selbst zu suchen? Ich habe es gefunden: http://stackoverflow.com/questions/10729116/adding-a-module-specifical-pymorph-to-spyder-python-ideal – ForceBru

Antwort

1

Vielleicht Conda versuchen Sie es mit ....

Ich hatte das gleiche Problem bei der Verwendung pip install graphviz und Anzeige der Plots in Jupyter. Das Problem ist, dass pip install ... GraphViz nicht tatsächlich installiert. Siehe die Dokumentation zu PyPi (graphviz 0.7 : Python Package Index); Sie müssen auch Graphviz installieren:

This package facilitates the creation and rendering of graph descriptions in the DOT language of the Graphviz graph drawing software (repo) from Python.

...

Installation

This package runs under Python 2.7, and 3.3+, use pip to install:

$ pip install graphviz 

To render the generated DOT source code, you also need to install Graphviz (download page).

Dieser arbeitete für mich (wieder mit Jupyter, nicht in Spyder getestet).

$ conda install python-graphviz 
# Fetching package metadata ............. 
# Solving package specifications: 

# The following NEW packages will be INSTALLED: 

#  graphviz:  2.38.0-3  bioconda 
#  python-graphviz: 0.5.2-py36_0   

Dann in Jupyter:

import pydotplus 

d_tree = tree.DecisionTreeClassifier() 
d_tree.fit(X_scaled, y) 

dot_data = tree.export_graphviz(d_tree, 
           out_file=None, 
           filled=True, 
           rounded=True, 
           special_characters=True) 
graph = pydotplus.graph_from_dot_data(dot_data) 

from IPython.display import Image 
Image(graph.create_png()) 

enter image description here