ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

FileNotFoundError: [WinError 2] "dot.exe" not found in path. #9543

Open MHDeveloping opened 6 years ago

MHDeveloping commented 6 years ago

Actual Behavior

it throws an error

using this code:

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") 

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

install Anaconda 1.8.7 for Win10 64bit
create an environment
get tensorflow installed
downlod graphviz-2.38 from "https://graphviz.gitlab.io/_pages/Download/Download_windows.html"
chose the zip file "2.38 Stable Release"
unzip it into C:\Users...Anaconda3\envs\NameOfEnv\Lib\site-packages
change the folder name from graphviz-2.38 to graphviz
first I kept it at this step. After it failed I copyed all folders which are under 'release' directly under 'graphviz'
copy scipy and sklearn into the site-packages folder
start jupyter
Write there this codelines:
import numpy as np
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
test_idx = [0,50,100]
#training data
train_target = np.delete(iris.target, test_idx)
train_data = np.delete(iris.data, test_idx, axis=0)

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")


##### Anaconda or Miniconda version:
Anaconda 1.8.7 for Win10 64bit

##### Operating System:
Win10 64bit

##### `conda info`
<!-- between the ticks below, paste the output of 'conda info' -->
shell level : 1
       user config file : C:\Users\ItsMe\.condarc
 populated config files : C:\Users\ItsMe\.condarc
          conda version : 4.4.10
    conda-build version : 3.4.1
         python version : 3.6.5.final.0
       base environment : C:\Users\ItsMe\Anaconda3  (writable)
           channel URLs : https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
          package cache : C:\Users\ItsMe\Anaconda3\pkgs
                          C:\Users\ItsMe\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\ItsMe\Anaconda3\envs
                          C:\Users\ItsMe\AppData\Local\conda\conda\envs
                          C:\Users\ItsMe\.conda\envs
               platform : win-64
             user-agent : conda/4.4.10 requests/2.18.4 CPython/3.6.5 Windows/10 Windows/10.0.14393
          administrator : False
             netrc file : None
           offline mode : False
conda list --show-channel-urls
Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he6757f0_0    defaults
alabaster                 0.7.10           py36hcd07829_0    defaults
anaconda-client           1.6.14                   py36_0    defaults
anaconda-navigator        1.8.7                    py36_0    defaults
anaconda-project          0.8.2            py36hfad2e28_0    defaults
asn1crypto                0.24.0                   py36_0    defaults
astroid                   1.6.1                    py36_0    defaults
astropy                   2.0.3            py36hfa6e2cd_0    defaults
attrs                     17.4.0                   py36_0    defaults
babel                     2.5.3                    py36_0    defaults
backports                 1.0              py36h81696a8_1    defaults
backports.shutil_get_terminal_size 1.0.0            py36h79ab834_2    defaults
beautifulsoup4            4.6.0            py36hd4cc5e8_1    defaults
bitarray                  0.8.1            py36hfa6e2cd_1    defaults
bkcharts                  0.2              py36h7e685f7_0    defaults
blaze                     0.11.3           py36h8a29ca5_0    defaults
bleach                    2.1.2                    py36_0    defaults
bokeh                     0.12.13          py36h047fa9f_0    defaults
boto                      2.48.0           py36h1a776d2_1    defaults
bottleneck                1.2.1            py36hd119dfa_0    defaults
bzip2                     1.0.6                hfa6e2cd_5    defaults
ca-certificates           2018.03.07                    0    defaults
certifi                   2018.4.16                py36_0    defaults
cffi                      1.11.5           py36h945400d_0    defaults
chardet                   3.0.4            py36h420ce6e_1    defaults
click                     6.7              py36hec8c647_0    defaults
cloudpickle               0.5.2                    py36_1    defaults
clyent                    1.2.2            py36hb10d595_1    defaults
colorama                  0.3.9            py36h029ae33_0    defaults
comtypes                  1.1.4                    py36_0    defaults
conda                     4.4.10                   py36_0    defaults
conda-build               3.4.1                    py36_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
conda-verify              2.0.0            py36h065de53_0    defaults
console_shortcut          0.1.1                h6bb2dd7_3    defaults
contextlib2               0.5.5            py36he5d52c0_0    defaults
cryptography              2.2.2            py36hfa6e2cd_0    defaults
curl                      7.58.0               h7602738_0    defaults
cycler                    0.10.0           py36h009560c_0    defaults
cython                    0.27.3           py36h22f4c84_0    defaults
cytoolz                   0.9.0            py36hfa6e2cd_0    defaults
dask                      0.16.1                   py36_0    defaults
dask-core                 0.16.1                   py36_0    defaults
datashape                 0.5.4            py36h5770b85_0    defaults
decorator                 4.3.0                    py36_0    defaults
distributed               1.20.2                   py36_0    defaults
docutils                  0.14             py36h6012d8f_0    defaults
entrypoints               0.2.3            py36hfd66bb0_2    defaults
et_xmlfile                1.0.1            py36h3d2d736_0    defaults
fastcache                 1.0.2            py36hfa6e2cd_2    defaults
filelock                  2.0.13           py36h20000bf_0    defaults
flask                     0.12.2           py36h98b5e8f_0    defaults
flask-cors                3.0.3            py36h8a3855d_0    defaults
freetype                  2.8                  h51f8f2c_1    defaults
get_terminal_size         1.0.0                h38e98db_0    defaults
gevent                    1.2.2            py36h342a76c_0    defaults
glob2                     0.6              py36hdf76b57_0    defaults
greenlet                  0.4.12           py36ha00ad21_0    defaults
h5py                      2.7.1            py36he54a1c3_0    defaults
hdf5                      1.10.1               h98b8871_1    defaults
heapdict                  1.0.0                    py36_2    defaults
html5lib                  1.0.1            py36h047fa9f_0    defaults
icc_rt                    2017.0.4             h97af966_0    defaults
icu                       58.2                 ha66f8fd_1    defaults
idna                      2.6              py36h148d497_1    defaults
imageio                   2.2.0            py36had6c2d2_0    defaults
imagesize                 0.7.1            py36he29f638_0    defaults
intel-openmp              2018.0.0             hd92c6cd_8    defaults
ipykernel                 4.8.0                    py36_0    defaults
ipython                   6.2.1            py36h9cf0123_1    defaults
ipython_genutils          0.2.0            py36h3c5d0ee_0    defaults
ipywidgets                7.1.1                    py36_0    defaults
isort                     4.2.15           py36h6198cc5_0    defaults
itsdangerous              0.24             py36hb6c5a24_1    defaults
jdcal                     1.3              py36h64a5255_0    defaults
jedi                      0.11.1                   py36_0    defaults
jinja2                    2.10             py36h292fed1_0    defaults
jpeg                      9b                   hb83a4c4_2    defaults
jsonschema                2.6.0            py36h7636477_0    defaults
jupyter                   1.0.0                    py36_4    defaults
jupyter_client            5.2.2                    py36_0    defaults
jupyter_console           5.2.0            py36h6d89b47_1    defaults
jupyter_core              4.4.0            py36h56e9d50_0    defaults
jupyterlab                0.31.4                   py36_0    defaults
jupyterlab_launcher       0.10.2                   py36_0    defaults
lazy-object-proxy         1.3.1            py36hd1c21d2_0    defaults
libcurl                   7.58.0               h7602738_0    defaults
libiconv                  1.15                 h1df5818_7    defaults
libpng                    1.6.34               h79bbb47_0    defaults
libssh2                   1.8.0                hd619d38_4    defaults
libtiff                   4.0.9                hb8ad9f9_1    defaults
libxml2                   2.9.7                h79bbb47_0    defaults
libxslt                   1.1.32               hf6f1972_0    defaults
llvmlite                  0.21.0           py36he0b0552_0    defaults
locket                    0.2.0            py36hfed976d_1    defaults
lxml                      4.1.1            py36hef2cd61_1    defaults
lzo                       2.10                 h6df0209_2    defaults
markupsafe                1.0              py36h0e26971_1    defaults
matplotlib                2.1.2            py36h016c42a_0    defaults
mccabe                    0.6.1            py36hb41005a_1    defaults
menuinst                  1.4.11           py36hfa6e2cd_0    defaults
mistune                   0.8.3                    py36_0    defaults
mkl                       2018.0.1             h2108138_4    defaults
mkl-service               1.1.2            py36h57e144c_4    defaults
mpmath                    1.0.0            py36hacc8adf_2    defaults
msgpack-python            0.5.6            py36he980bc4_0    defaults
multipledispatch          0.4.9            py36he44c36e_0    defaults
navigator-updater         0.1.0            py36h8a7b86b_0    defaults
nbconvert                 5.3.1            py36h8dc0fde_0    defaults
nbformat                  4.4.0            py36h3a5bc1b_0    defaults
networkx                  2.1                      py36_0    defaults
nltk                      3.2.5            py36h76d52bb_0    defaults
nose                      1.3.7            py36h1c3779e_2    defaults
notebook                  5.4.0                    py36_0    defaults
numba                     0.36.2          np114py36h12cb543_0    defaults
numexpr                   2.6.4            py36h30784b8_0    defaults
numpy                     1.14.0           py36h4a99626_1    defaults
numpydoc                  0.7.0            py36ha25429e_0    defaults
odo                       0.5.1            py36h7560279_0    defaults
olefile                   0.45.1                   py36_0    defaults
openpyxl                  2.4.10                   py36_0    defaults
openssl                   1.0.2o               h8ea7d77_0    defaults
packaging                 17.1                     py36_0    defaults
pandas                    0.22.0           py36h6538335_0    defaults
pandoc                    1.19.2.1             hb2460c7_1    defaults
pandocfilters             1.4.2            py36h3ef6317_1    defaults
parso                     0.1.1            py36hae3edee_0    defaults
partd                     0.3.8            py36hc8e763b_0    defaults
path.py                   10.5             py36h2b94a8f_0    defaults
pathlib2                  2.3.0            py36h7bfb78b_0    defaults
patsy                     0.5.0                    py36_0    defaults
pep8                      1.7.1                    py36_0    defaults
pickleshare               0.7.4            py36h9de030f_0    defaults
pillow                    5.1.0            py36h0738816_0    defaults
pip                       10.0.1                   py36_0    defaults
pkginfo                   1.4.1            py36hb0f9cfa_1    defaults
pluggy                    0.6.0            py36hc7daf1e_0    defaults
ply                       3.10             py36h1211beb_0    defaults
prompt_toolkit            1.0.15           py36h60b8f86_0    defaults
psutil                    5.4.5            py36hfa6e2cd_0    defaults
py                        1.5.2            py36hbcfbabc_0    defaults
pycodestyle               2.3.1            py36h7cc55cd_0    defaults
pycosat                   0.6.3            py36h413d8a4_0    defaults
pycparser                 2.18             py36hd053e01_1    defaults
pycrypto                  2.6.1            py36hfa6e2cd_7    defaults
pycurl                    7.43.0.1         py36h74b6da3_0    defaults
pyflakes                  1.6.0            py36h0b975d6_0    defaults
pygments                  2.2.0            py36hb010967_0    defaults
pylint                    1.8.2                    py36_0    defaults
pyodbc                    4.0.22           py36h6538335_0    defaults
pyopenssl                 18.0.0                   py36_0    defaults
pyparsing                 2.2.0            py36h785a196_1    defaults
pyqt                      5.6.0            py36hb5ed885_5    defaults
pysocks                   1.6.8                    py36_0    defaults
pytables                  3.4.2            py36h71138e3_2    defaults
pytest                    3.3.2                    py36_0    defaults
python                    3.6.5                h0c2934d_0    defaults
python-dateutil           2.7.3                    py36_0    defaults
pytz                      2018.4                   py36_0    defaults
pywavelets                0.5.2            py36hc649158_0    defaults
pywin32                   222              py36hfa6e2cd_0    defaults
pywinpty                  0.5              py36h6538335_1    defaults
pyyaml                    3.12             py36h1d1928f_1    defaults
pyzmq                     16.0.3           py36he714bf5_0    defaults
qt                        5.6.2           vc14h6f8c307_12  [vc14]  defaults
qtawesome                 0.4.4            py36h5aa48f6_0    defaults
qtconsole                 4.3.1            py36h99a29a9_0    defaults
qtpy                      1.4.2                    py36_0    defaults
requests                  2.18.4           py36h4371aae_1    defaults
rope                      0.10.7           py36had63a69_0    defaults
ruamel_yaml               0.15.37          py36hfa6e2cd_2    defaults
scikit-image              0.13.1           py36hfa6e2cd_1    defaults
scikit-learn              0.19.1           py36h53aea1b_0    defaults
scipy                     1.0.0            py36h1260518_0    defaults
seaborn                   0.8.1            py36h9b69545_0    defaults
send2trash                1.4.2                    py36_0    defaults
setuptools                39.2.0                   py36_0    defaults
simplegeneric             0.8.1                    py36_2    defaults
singledispatch            3.4.0.3          py36h17d0c80_0    defaults
sip                       4.18.1           py36h9c25514_2    defaults
six                       1.11.0           py36h4db2310_1    defaults
snowballstemmer           1.2.1            py36h763602f_0    defaults
sortedcollections         0.5.3            py36hbefa0ab_0    defaults
sortedcontainers          1.5.9                    py36_0    defaults
sphinx                    1.6.6                    py36_0    defaults
sphinxcontrib             1.0              py36hbbac3d2_1    defaults
sphinxcontrib-websupport  1.0.1            py36hb5e5916_1    defaults
spyder                    3.2.6                    py36_0    defaults
sqlalchemy                1.2.1            py36hfa6e2cd_0    defaults
sqlite                    3.23.1               h35aae40_0    defaults
statsmodels               0.8.0            py36h6189b4c_0    defaults
sympy                     1.1.1            py36h96708e0_0    defaults
tblib                     1.3.2            py36h30f5020_0    defaults
terminado                 0.8.1                    py36_1    defaults
testpath                  0.3.1            py36h2698cfe_0    defaults
tk                        8.6.7                hcb92d03_3    defaults
toolz                     0.9.0                    py36_0    defaults
tornado                   5.0.2                    py36_0    defaults
traitlets                 4.3.2            py36h096827d_0    defaults
typing                    3.6.2            py36hb035bda_0    defaults
unicodecsv                0.14.1           py36h6450c06_0    defaults
urllib3                   1.22             py36h276f60a_0    defaults
vc                        14                   h0510ff6_3    defaults
vs2015_runtime            14.0.25123                    3    defaults
wcwidth                   0.1.7            py36h3d5aa90_0    defaults
webencodings              0.5.1            py36h67c50ae_1    defaults
werkzeug                  0.14.1                   py36_0    defaults
wheel                     0.31.1                   py36_0    defaults
widgetsnbextension        3.1.0                    py36_0    defaults
win_inet_pton             1.0.1            py36he67d7fd_1    defaults
win_unicode_console       0.5              py36hcdbd4b5_0    defaults
wincertstore              0.2              py36h7fe50ca_0    defaults
winpty                    0.4.3                         4    defaults
wrapt                     1.10.11          py36he5f5981_0    defaults
xlrd                      1.1.0            py36h1cb58dc_1    defaults
xlsxwriter                1.0.2            py36hf723b7d_0    defaults
xlwings                   0.11.5                   py36_0    defaults
xlwt                      1.3.0            py36h1a4751e_0    defaults
yaml                      0.1.7                hc54c509_2    defaults
zict                      0.1.3            py36h2d8e73e_0    defaults
zlib                      1.2.11               h8395fce_2    defaults
MHDeveloping commented 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

MHDeveloping commented 6 years ago

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.

heator commented 5 years ago

Please use pydotplus instead of pydot

  1. Find:C:\Users\zhangqianyuan\AppData\Local\Programs\Python\Python36\Lib\site-packages\pydotplus

  2. Open graphviz.py

  3. Find line 1925 - line 1972, find the function:

    def create(self, prog=None, format='ps'):
  4. 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])
        )
  5. Between the two block add this(Your Graphviz's executable path):

      self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"`
  6. 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])
        )
  7. save the changed file then you can run it successfully.

  8. you'd better save it as bmp file because png file will not work. picture is here

@MHDeveloping

gitgithan commented 4 years ago

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?

harshitrana672 commented 2 weeks ago

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