Open MHDeveloping opened 6 years ago
To fix this, (mentioned in the first comment) UnsatisfiableError: The following specifications were found to be in conflict: pydot-ng tensorflow Use "conda info " to see the dependencies for each package.** conda update --all_
I found that: [https://stackoverflow.com/questions/26349314/how-can-i-use-conda-to-install-pydot] followed whats written at mark 12(measn I had to install git as well) Because of conda list shows nothing of pydot, I copyed it manually to C:...\NameOfEnv\Lib\site-packages
Finally it comes to this error: FileNotFoundError Traceback (most recent call last) ~\Anaconda3\envs\NameOfEnv\lib\site-packages\pydot.py in create(self, prog, format, encoding)
So, still the same
I missd something under that link, there is 'conda list' (use conda prompt, not the win prompt) it did not list/show any of pydot.
Please use pydotplus instead of pydot
Find:C:\Users\zhangqianyuan\AppData\Local\Programs\Python\Python36\Lib\site-packages\pydotplus
Open graphviz.py
Find line 1925 - line 1972, find the function:
def create(self, prog=None, format='ps'):
In the function find:
if prog not in self.progs:
raise InvocationException(
'GraphViz\'s executable "%s" not found' % prog)
if not os.path.exists(self.progs[prog]) or \
not os.path.isfile(self.progs[prog]):
raise InvocationException(
'GraphViz\'s executable "{}" is not'
' a file or doesn\'t exist'.format(self.progs[prog])
)
Between the two block add this(Your Graphviz's executable path):
self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"`
After adding the result is:
if prog not in self.progs:
raise InvocationException(
'GraphViz\'s executable "%s" not found' % prog)
self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"
if not os.path.exists(self.progs[prog]) or \
not os.path.isfile(self.progs[prog]):
raise InvocationException(
'GraphViz\'s executable "{}" is not'
' a file or doesn\'t exist'.format(self.progs[prog])
)
save the changed file then you can run it successfully.
you'd better save it as bmp file because png file will not work. picture is here
@MHDeveloping
I was trying to use from keras.utils.vis_utils import model_to_dot
today to plot the neural network.
I traced through the high level OS Error into your lower level FileNotFound error.
I did pip install pydot
before getting that error.
Then i tried pip uninstall pydot
and conda install pydot
and saw 3 packages installed
graphviz-2.38-hfd603c8_2
pydot-1.4.1-py37_0
pyparsing-2.4.0-py_0
installed in Anaconda3/pkgs
and now it works!
So maybe you want to try conda install rather than pip install?
However, my issue is keras not sklearn decision tree. I had no problem ploting tree using pip install pydotplus
and installing graphviz from https://www.graphviz.org/ and then setting PATH variable.
I'm not sure the difference between the graphviz-2.38-hfd603c8_2 from conda install and the graphviz from my manual download msi and install from the website.
Also not sure difference between pydot and pydotplus in plotting decisiontree. If someone knows please enlighten me?
I used a different approach to solve this problem . I had downloaded the graphviz 64 bit version and installed it Then confirm the installation using dot -V command then restart your IDE in order to reflect the change . Then run the same code again for me I have used this code :
from IPython.display import Image
from io import StringIO
from sklearn.tree import export_graphviz
import pydot
import graphviz
features = list(df.columns[1:])
features
dot_data = StringIO()
export_graphviz(dtree, out_file=dot_data,feature_names=features,filled=True,rounded=True)
graph = pydot.graph_from_dot_data(dot_data.getvalue())
Image(graph[0].create_png())
this works fine for me on Windows 10 let me know your thoughts
Actual Behavior
it throws an error
using this code:
and it throws this error: _*\Anaconda3\envs\NameOfEnv\lib\site-packages\pydot.py in create(self, prog, format, encoding) 1865 args[1] = '"{prog}" not found in path.'.format( 1866 prog=prog) -> 1867 raise OSError(args) 1868 else: 1869 raise
FileNotFoundError: [WinError 2] "dot.exe" not found in path.**_
To fix it I:
Here at this point, I did not know what to do with "see the dependencies" If I see it... then what? Pages talking mostly about update --all, so I did, but it came again to the conflict
Expected Behavior
creates the pdf iris
Steps to Reproduce
testin data
test_target = iris.target[test_idx] test_data = iris.data[test_idx]
clf = tree.DecisionTreeClassifier() clf.fit(train_data, train_target)
print (test_target)
print(clf.predict(test_data))
Visualize the tree```
from sklearn.externals.six import StringIO import pydot dot_data = StringIO() tree.export_graphviz(clf, out_file=dot_data, feature_names=iris.feature_names, class_names=iris.target_names, filled=True, rounded=True, impurity=False) graph = pydot.graph_from_dot_data(dot_data.getvalue()) graph[0].write_pdf("iris.pdf")
conda list --show-channel-urls