Giter Site home page Giter Site logo

Comments (36)

MirkosMartins avatar MirkosMartins commented on August 28, 2024 57

I solved with this 2 steps:

  • install Graphviz after download installer (https://www.graphviz.org/)
  • insert in code this two lines:
    import os
    os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'

from deepreinforcementlearning.

davidADSP avatar davidADSP commented on August 28, 2024 40

brew install graphviz
or equivalent should fix this

from deepreinforcementlearning.

xjzhou avatar xjzhou commented on August 28, 2024 13

@jbarrigapartarrieu make sure you have Graphviz installed separately on your system, not just in your project directory. You can find source and executable package installers here: https://www.graphviz.org/download/

in Ubuntu, I use 'apt-get install graphviz', then , it sovled.

from deepreinforcementlearning.

onomatopeia avatar onomatopeia commented on August 28, 2024 11

@Kiran-kkt You need to install Graphviz with conda, and not from the binaries.
See here for syntax: https://anaconda.org/anaconda/graphviz
It's probably better to uninstall Graphviz first, but actually I'm not sure if there would be any clash.

Reason: Pydot checks whether you have graphviz installed by calling the dot executable. On Windows it appends an extension "exe" unless you have Anaconda, in which case it appends "bat". You can check that your Graphviz installation from binaries has only "dot.exe". So since pydot tries to execute "dot.bat" you;'re getting the error.
You can see it in Pydot's sources here: https://github.com/pydot/pydot/blob/master/pydot.py#L103-L108

from deepreinforcementlearning.

rajneeshaggarwal avatar rajneeshaggarwal commented on August 28, 2024 11

It worked with the following command on windows 10:

conda install graphviz

from deepreinforcementlearning.

24rochak avatar 24rochak commented on August 28, 2024 9

If you have setup the PATH variable in Windows and still the same error shows up in any IDE like PyCharm, then restart your IDE. It fixes the error as the PATH variable does not get updated dynamically.

from deepreinforcementlearning.

jdori avatar jdori commented on August 28, 2024 8

@jbarrigapartarrieu make sure you have Graphviz installed separately on your system, not just in your project directory. You can find source and executable package installers here: https://www.graphviz.org/download/

from deepreinforcementlearning.

Kiran-kkt avatar Kiran-kkt commented on August 28, 2024 6

@MirkosMartins The issue still persists for me even after doing the same as you did.

from deepreinforcementlearning.

ifjgm005 avatar ifjgm005 commented on August 28, 2024 6

I solved with this 2 steps on Linux

  1. conda install -c conda-forge graphviz
  2. restart jupyter notebook
    then ,it solved!

from deepreinforcementlearning.

DataInformer avatar DataInformer commented on August 28, 2024 5

I used https://stackoverflow.com/questions/40632486/dot-exe-not-found-in-path-pydot-on-python-windows-7 to get past a similar issue

from deepreinforcementlearning.

Denkisen avatar Denkisen commented on August 28, 2024 4

On Windows 10:

  • Run PowerShell as Adnin
  • dot -c

from deepreinforcementlearning.

mombo84 avatar mombo84 commented on August 28, 2024 3

I had the same issue and the install of graphviz via Anaconda solved it for me on Windows 8.1.
I used this one:
conda install -c anaconda python-graphviz

I found it at the link below.
https://anaconda.org/anaconda/python-graphviz

from deepreinforcementlearning.

rytisss avatar rytisss commented on August 28, 2024 3

On Windows 10:

  • Run PowerShell as Adnin
  • dot -c

This reply helped!
Use PowerShell!

from deepreinforcementlearning.

dalek7 avatar dalek7 commented on August 28, 2024 2

@jbarrigapartarrieu make sure you have Graphviz installed separately on your system, not just in your project directory. You can find source and executable package installers here: https://www.graphviz.org/download/

in Ubuntu, I use 'apt-get install graphviz', then , it sovled.

This worked for me !

from deepreinforcementlearning.

ThisuriLekamge avatar ThisuriLekamge commented on August 28, 2024 1

@jbarrigapartarrieu make sure you have Graphviz installed separately on your system, not just in your project directory. You can find source and executable package installers here: https://www.graphviz.org/download/

in Ubuntu, I use 'apt-get install graphviz', then , it sovled.

This worked @xjzhou

from deepreinforcementlearning.

Junliu-521 avatar Junliu-521 commented on August 28, 2024 1

On Windows 10:

  • Run PowerShell as Adnin
  • dot -c

This reply helped!
Use PowerShell!

yes,this is very useful

from deepreinforcementlearning.

nickyongzhang avatar nickyongzhang commented on August 28, 2024

Same issue for me. Thanks to @jdori , I use homebrew to install graphviz and the problem sovled.

from deepreinforcementlearning.

ujinyng avatar ujinyng commented on August 28, 2024

@DataInformer thank you

from deepreinforcementlearning.

MirkosMartins avatar MirkosMartins commented on August 28, 2024

@MirkosMartins The issue still persists for me even after doing the same as you did.

Kiran-kkt, could you send me the error message?

from deepreinforcementlearning.

Kiran-kkt avatar Kiran-kkt commented on August 28, 2024

@MirkosMartins The issue still persists for me even after doing the same as you did.

Kiran-kkt, could you send me the error message?

Error message:


FileNotFoundError

                     Traceback (most recent call last)

C:\Program Files\Anaconda3\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1914 arguments=arguments,
-> 1915 working_dir=tmp_dir,
1916 )

C:\Program Files\Anaconda3\lib\site-packages\pydot.py in call_graphviz(program, arguments, working_dir, **kwargs)
135 stdout=subprocess.PIPE,
--> 136 **kwargs
137 )

C:\Program Files\Anaconda3\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
946 errread, errwrite,
--> 947 restore_signals, start_new_session)
948 except:

C:\Program Files\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1223 cwd,
-> 1224 startupinfo)
1225 finally:

FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

During handling of the above exception, another exception occurred:

FileNotFoundError Traceback (most recent call last)
C:\Program Files\Anaconda3\lib\site-packages\keras\utils\vis_utils.py in _check_pydot()
25 # to check the pydot/graphviz installation.
---> 26 pydot.Dot.create(pydot.Dot())
27 except OSError:

C:\Program Files\Anaconda3\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1921 prog=prog)
-> 1922 raise OSError(*args)
1923 else:

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

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last)
in ()
7 model.add(Dense(2, input_dim=1, activation='relu'))
8 model.add(Dense(1, activation='sigmoid'))
----> 9 plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

C:\Program Files\Anaconda3\lib\site-packages\keras\utils\vis_utils.py in plot_model(model, to_file, show_shapes, show_layer_names, rankdir)
130 'LR' creates a horizontal plot.
131 """
--> 132 dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)
133 _, extension = os.path.splitext(to_file)
134 if not extension:

C:\Program Files\Anaconda3\lib\site-packages\keras\utils\vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir)
53 from ..models import Sequential
54
---> 55 _check_pydot()
56 dot = pydot.Dot()
57 dot.set('rankdir', rankdir)

C:\Program Files\Anaconda3\lib\site-packages\keras\utils\vis_utils.py in _check_pydot()
27 except OSError:
28 raise OSError(
---> 29 'pydot failed to call GraphViz.'
30 'Please install GraphViz (https://www.graphviz.org/) '
31 'and ensure that its executables are in the $PATH.')

OSError: pydot failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.

Sample code:

from keras.models import Sequential
from keras.layers import Dense
from keras.utils.vis_utils import plot_model
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
model = Sequential()
model.add(Dense(2, input_dim=1, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

User path variable:

user varaibles

from deepreinforcementlearning.

Kiran-kkt avatar Kiran-kkt commented on August 28, 2024

@onomatopeia I've installed Graphviz via conda and now I get a new error like this.

Error message:


AssertionError Traceback (most recent call last)
in
7 model.add(Dense(2, input_dim=1, activation='relu'))
8 model.add(Dense(1, activation='sigmoid'))
----> 9 plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

C:\ProgramData\Anaconda3\envs\masterprjt_v_1.0\lib\site-packages\keras\utils\vis_utils.py in plot_model(model, to_file, show_shapes, show_layer_names, rankdir)
130 'LR' creates a horizontal plot.
131 """
--> 132 dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)
133 _, extension = os.path.splitext(to_file)
134 if not extension:

C:\ProgramData\Anaconda3\envs\masterprjt_v_1.0\lib\site-packages\keras\utils\vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir)
53 from ..models import Sequential
54
---> 55 _check_pydot()
56 dot = pydot.Dot()
57 dot.set('rankdir', rankdir)

C:\ProgramData\Anaconda3\envs\masterprjt_v_1.0\lib\site-packages\keras\utils\vis_utils.py in _check_pydot()
24 # Attempt to create an image of a blank graph
25 # to check the pydot/graphviz installation.
---> 26 pydot.Dot.create(pydot.Dot())
27 except OSError:
28 raise OSError(

C:\ProgramData\Anaconda3\envs\masterprjt_v_1.0\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1883 out=stdout_data,
1884 err=stderr_data))
-> 1885 assert p.returncode == 0, p.returncode
1886 return stdout_data

AssertionError: 1

Line #24 #25 suggests me that its checking for graphviz installation. I've also looked up in stackoverflow and I see the same answer

I also tried this by installing python package anaconda python-graphviz but of no use.

I don't understand why this problem still exsists it's kind of wierd.

from deepreinforcementlearning.

onomatopeia avatar onomatopeia commented on August 28, 2024

Sorry to hear that @Kiran-kkt, this solution worked on my machine :(.
Anyway, the error you're getting says that the subprocess ended with exit code = 1.

Are you also getting an error message (just before the AssertionError) - something like

message = '"{prog}" with args {arguments} returned code: {code}\n\n'
                'stdout, stderr:\n {out}\n{err}\n'

Maybe that gives more details as to what is going on?

This message is formed and displayed in the latest version of pydot, but from the line numbers in your stack trace I can see that you have some older version. Could you check what version that is? (e.g. by running pip freeze from the command line inside the virtual environment)

from deepreinforcementlearning.

sakurakhadag avatar sakurakhadag commented on August 28, 2024

@onomatopeia Thanks. Installing with conda worked for me.

from deepreinforcementlearning.

Kiran-kkt avatar Kiran-kkt commented on August 28, 2024

@onomatopeia Here is the message

"dot" with args ['-Tps', 'C:\\Users\\TUNUGU~1\\AppData\\Local\\Temp\\tmp4dwfnf5z'] returned code: 1

stdout, stderr:
 b''
b''

pydot version is 1.4.1 and graphviz version is 2.38

from deepreinforcementlearning.

onomatopeia avatar onomatopeia commented on August 28, 2024

Ah, that is so unhelpful!
Ok, some last checks before I give up.
In the command line activate your virtual env, type where dot. This is just a sanity check, the path should be something like <path_to_anaconda>\envs\<your_virtual_env>\Library\bin\dot.bat.

Then check that this file actually exists: C:\\Users\\TUNUGU~1\\AppData\\Local\\Temp\\tmp4dwfnf5z (I copied it from your post). Run (still from the command line inside the virtual env) dot -Tps C:\\Users\\TUNUGU~1\\AppData\\Local\\Temp\\tmp4dwfnf5z
That should generate a lot of textual output, and no errors.

If any of the above fails I would advise reinstalling graphviz (with conda).

from deepreinforcementlearning.

Kiran-kkt avatar Kiran-kkt commented on August 28, 2024

@onomatopeia Thank you very much for the help. I'll get back to you if I get it right.

from deepreinforcementlearning.

qntbkk avatar qntbkk commented on August 28, 2024

brew install graphviz
or equivalent should fix this

be careful, it will remove all python link

from deepreinforcementlearning.

RushiBhatt007 avatar RushiBhatt007 commented on August 28, 2024

"dot" with args ['-Tps', 'C:\Users\RUSHI\AppData\Local\Temp\tmpc4sohz9l'] returned code: 1

stdout, stderr:
b''
b"'C:\Users\RUSHI\Anaconda' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"


AssertionError                            Traceback (most recent call last)
<ipython-input-2-39ccd97d46fc> in <module>
     39 #copy the config file to the run folder
     40 copyfile('./config.py', run_folder + 'config.py')
---> 41 plot_model(current_NN.model, to_file=run_folder + 'models/model.png', show_shapes = True)
     42 
     43 print('\n')

~\Anaconda Python\envs\tf-gpu\lib\site-packages\keras\utils\vis_utils.py in plot_model(model, to_file, show_shapes, show_layer_names, rankdir, expand_nested, dpi)
    238     """
    239     dot = model_to_dot(model, show_shapes, show_layer_names, rankdir,
--> 240                        expand_nested, dpi)
    241     _, extension = os.path.splitext(to_file)
    242     if not extension:

~\Anaconda Python\envs\tf-gpu\lib\site-packages\keras\utils\vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir, expand_nested, dpi, subgraph)
     77     from ..models import Sequential
     78 
---> 79     _check_pydot()
     80     if subgraph:
     81         dot = pydot.Cluster(style='dashed', graph_name=model.name)

~\Anaconda Python\envs\tf-gpu\lib\site-packages\keras\utils\vis_utils.py in _check_pydot()
     26         # Attempt to create an image of a blank graph
     27         # to check the pydot/graphviz installation.
---> 28         pydot.Dot.create(pydot.Dot())
     29     except OSError:
     30         raise OSError(

~\Anaconda Python\envs\tf-gpu\lib\site-packages\pydot.py in create(self, prog, format, encoding)
   1943             print(message)
   1944 
-> 1945         assert process.returncode == 0, process.returncode
   1946 
   1947         return stdout_data

AssertionError: 1

I get this error. Someone please help. I've already tried doing:

  1. pip install graphviz
  2. conda install graphviz
  3. Downloading graphviz on my system and manually adding its path to environment variable in my script
  4. Adding downloaded graphviz's bin folder to the environment variable

Nothing worked for me. If someone can please help out would be really helpful. Thanks!

from deepreinforcementlearning.

BillTuer avatar BillTuer commented on August 28, 2024

On Windows 10:

* Run PowerShell as Adnin

* `dot -c`

So much time lost but so easy to fix. Thank you so much!

from deepreinforcementlearning.

inspirepassion avatar inspirepassion commented on August 28, 2024

For Mac, that's how it works for my case:

pydot:
pip3 install pydot

graphviz:
(note it doesn't work if just pip3 install graphviz, even it's listed under pip3 list)
This works:
brew install graphviz, as indicated by them (https://www.graphviz.org/download/) (note you might need to install brew first on you Mac, so copy and paste this line in terminal and run to install brew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)")

from deepreinforcementlearning.

Naveen-2506 avatar Naveen-2506 commented on August 28, 2024

@jbarrigapartarrieu make sure you have Graphviz installed separately on your system, not just in your project directory. You can find source and executable package installers here: https://www.graphviz.org/download/

in Ubuntu, I use 'apt-get install graphviz', then , it sovled.

This worked @xjzhou

Thank you for your share

from deepreinforcementlearning.

budaesandrei avatar budaesandrei commented on August 28, 2024

I solved with this 2 steps on Linux

  1. conda install -c conda-forge graphviz
  2. restart jupyter notebook
    then ,it solved!

I can confirm this worked on Windows too. Thanks

from deepreinforcementlearning.

ItsShraddhaMishra avatar ItsShraddhaMishra commented on August 28, 2024
  1. Install Graphviz from https://www.graphviz.org/download/
  2. Import:
    from tensorflow.python.keras.utils.vis_utils import model_to_dot
    from tensorflow.python.keras.utils.vis_utils import plot_model

from deepreinforcementlearning.

kirillchertoganov avatar kirillchertoganov commented on August 28, 2024

I did this:
"Install Graphviz from https://www.graphviz.org/download/
Import:
from tensorflow.python.keras.utils.vis_utils import model_to_dot
from tensorflow.python.keras.utils.vis_utils import plot_model"

and I have this:
UnimplementedError: The Conv2D op currently only supports the NHWC tensor format on the CPU. The op was given the format: NCHW
[[node model_9/conv2d_117/Conv2D (defined at C:\Users\Admin\Desktop\finantial risk\DeepReinforcementLearning-master\model.py:30) ]] [Op:__inference_predict_function_10471]

Function call stack:
predict_function

from deepreinforcementlearning.

ItsShraddhaMishra avatar ItsShraddhaMishra commented on August 28, 2024

NHWC tensor format
All you need to do is a permutation of the dimensions from NHWC to NCHW (or the contrary).
[(https://stackoverflow.com/questions/37689423/convert-between-nhwc-and-nchw-in-tensorflow)]

from deepreinforcementlearning.

archcra avatar archcra commented on August 28, 2024

from deepreinforcementlearning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.