Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphviz.backend.CalledProcessError: Command '['dot.bat', '-Tpng']' returned non-zero exit status 1. #43

Closed
oliinykmd opened this issue Apr 5, 2020 · 8 comments · Fixed by #64

Comments

@oliinykmd
Copy link

Hi!
I'm sorry, actually I'm a doctor, so again, I'm sorry for my code and explanation, but here is the error

Code:
xgb.plot_tree(model, num_trees=0)
rcParams['figure.figsize'] = 80, 50

'C:\Users\Ruslan' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:/Users/Ruslan Oliinyk/PycharmProjects/XGB_Facebook/income.py", line 89, in
xgb.plot_tree(model, num_trees=0)
File "C:\Users\Ruslan Oliinyk\Anaconda3\lib\site-packages\xgboost\plotting.py", line 281, in plot_tree
s.write(g.pipe(format='png'))
File "C:\Users\Ruslan Oliinyk\Anaconda3\lib\site-packages\graphviz\files.py", line 138, in pipe
quiet=quiet)
File "C:\Users\Ruslan Oliinyk\Anaconda3\lib\site-packages\graphviz\backend.py", line 231, in pipe
out, _ = run(cmd, input=data, capture_output=True, check=True, quiet=quiet)
File "C:\Users\Ruslan Oliinyk\Anaconda3\lib\site-packages\graphviz\backend.py", line 174, in run
output=out, stderr=err)
graphviz.backend.CalledProcessError: Command '['dot.bat', '-Tpng']' returned non-zero exit status 1. [stderr: b"'C:\Users\Ruslan' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"]

Thank you!

@jakirkham
Copy link
Member

Thanks for the report! Could you please include information from the environment where this was run? Should just be conda list if the environment is active 🙂

@peternowee
Copy link
Contributor

I have seen a similar bug report in pydot/pydot#207. Both here and there, the user has a space character in the directory path. A possible solution may be to wrap the executable in double quotes in line 37 of recipe/bld.bat. Change that line from:

echo %%~dp0.\graphviz\%%~nf.exe %%* >> %%~nf.bat

to:

echo "%%~dp0.\graphviz\%%~nf.exe" %%* >> %%~nf.bat

I did a very quick, simple test of a batch script like that in Windows 10 and the resulting dot.bat contained:

"%~dp0.\graphviz\dot.exe" %*

Hopefully that allows for spaces in the directory path. I only have limited access to Windows, so please test it yourself as well.

@oliinykmd Maybe you can try this out by finding dot.bat on your system. Maybe in a directory like:

C:\Users\Ruslan Oliinyk\Anaconda3\Library\bin\dot.bat

It probably contains a line like:

%~dp0.\graphviz\dot.exe %*

Put double quotes around that first part:

"%~dp0.\graphviz\dot.exe" %*

Please report back if that prevents the error.

Some resources in case you are wondering about the meaning of all those percent signs:

@ccordoba12
Copy link
Contributor

@peternowee, could you submit a PR with your fix here?

@peternowee
Copy link
Contributor

@ccordoba12 Sorry, but I do not feel certain enough about the fix to do that. I do not use Windows, conda or conda-forge myself right now, so I cannot oversee possible side-effects of this and I am not able to do extensive testing. I only did a very quick manual run of a manually created batch file containing only this snippet of code on a Windows CI VM to see if the dot.bat file was written correctly and it was. I did not check if dot.bat actually executed dot.exe correctly, with all its arguments, for example. Someone with more experience with this project and better access to Windows needs to also have a look at it and maybe do a test conda install in a path with a space character in it to see if it really works. If it works, feel free to make the commit under your own name.

@slacker298
Copy link

slacker298 commented Jul 4, 2020

I have seen a similar bug report in pydot/pydot#207. Both here and there, the user has a space character in the directory path. A possible solution may be to wrap the executable in double quotes in line 37 of recipe/bld.bat. Change that line from:

echo %%~dp0.\graphviz\%%~nf.exe %%* >> %%~nf.bat

to:

echo "%%~dp0.\graphviz\%%~nf.exe" %%* >> %%~nf.bat

I did a very quick, simple test of a batch script like that in Windows 10 and the resulting dot.bat contained:

"%~dp0.\graphviz\dot.exe" %*

Hopefully that allows for spaces in the directory path. I only have limited access to Windows, so please test it yourself as well.

@oliinykmd Maybe you can try this out by finding dot.bat on your system. Maybe in a directory like:

C:\Users\Ruslan Oliinyk\Anaconda3\Library\bin\dot.bat

It probably contains a line like:

%~dp0.\graphviz\dot.exe %*

Put double quotes around that first part:

"%~dp0.\graphviz\dot.exe" %*

Please report back if that prevents the error.

Some resources in case you are wondering about the meaning of all those percent signs:

This worked for me!
Windows 10, pydot 1.4.1, graphviz-2.44.1 (installed from https://www2.graphviz.org/Packages/stable/windows/10/msbuild/Release/Win32/)

Trying to run the line keras.utils.plot_model(model, "my_first_model.png") from https://keras.io/guides/functional_api/

My anaconda3 environments were installed in Users/Bryan Lanier/... and I was also getting same error since it would complain about 'C:\Users\Bryan...'

The quotes around the code in dot.bat was all I needed. Only thing to note was, that for me, I had to find the dot.bat that was in
environment I had installed it in! For me, that was C:\Users\Bryan Lanier\anaconda3\envs\py37\Library\bin

Thanks a million for finding this simple fix

@umerbaloch
Copy link

It took me so many search to find this simple fix. Thanks!!!!!!

@jakirkham
Copy link
Member

Could someone please retest this with the latest packages?

@jakirkham
Copy link
Member

Going to tentatively close. We are now building Windows from source with PR ( #59 ). So no longer include or need this batch script

peternowee added a commit to peternowee/graphviz-feedstock that referenced this issue Feb 22, 2021
Should prevent problems finding the Graphviz executables when using the
legacy `.bat` files.

Should fix conda-forge#43
peternowee added a commit to peternowee/graphviz-feedstock that referenced this issue Feb 22, 2021
Should prevent problems finding the Graphviz executables when using the
legacy `.bat` files.

Should fix conda-forge#43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants