Skip to content

Graphviz executable not found due to space in path (returncode 1, and assertionError 1) #207

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

Closed
jryzj opened this issue Mar 15, 2019 · 3 comments

Comments

@jryzj
Copy link

jryzj commented Mar 15, 2019

Hi, my code is as below,

import pydot pydot.Dot.create(pydot.Dot())

the error is,
`
['dot.bat', '-Tps', 'C:\Users\Jry\AppData\Local\Temp\tmppcmwp3ua'] return code: 1

stdout, stderr:
b''
b"'D:\Program' \xb2\xbb\xca\xc7\xc4\xda\xb2\xbf\xbb\xf2\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\xa3\xac\xd2\xb2\xb2\xbb\xca\xc7\xbf\xc9\xd4\xcb\xd0\xd0\xb5\xc4\xb3\xcc\xd0\xf2\r\n\xbb\xf2\xc5\xfa\xb4\xa6\xc0\xed\xce\xc4\xbc\xfe\xa1\xa3\r\n"

Traceback (most recent call last):
File "", line 1, in
File "D:\Program Files\Anaconda3\lib\site-packages\pydot.py", line 1886, in create
assert p.returncode == 0, p.returncode
AssertionError: 1
`

I read Pydot.py, found in line 1834, the code is,
prog += '.bat'
so I revise the line to
prog += '.exe'

then it works.

I use Anaconda, the installation path is D:\Program Files\Anaconda3.
the reason, I think, is the space in command path - 'Program Files' in dot.bat makes subprocess.Popen down.

So hope this can be solve in next version :-)

@peternowee
Copy link
Member

The error message at the top is GB2312 (Simplified Chinese) encoded and does indeed indicate some problem with the space character in D:\Program Files:

$ python3
>>> print(b"'D:\Program' \xb2\xbb\xca\xc7\xc4\xda\xb2\xbf\xbb\xf2\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\xa3\xac\xd2\xb2\xb2\xbb\xca\xc7\xbf\xc9\xd4\xcb\xd0\xd0\xb5\xc4\xb3\xcc\xd0\xf2\r\n\xbb\xf2\xc5\xfa\xb4\xa6\xc0\xed\xce\xc4\xbc\xfe\xa1\xa3\r\n".decode('gb2312'))
'D:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

In English that would be:

'D:\Program' is not recognized as an internal or external command, 
operable program or batch file

So, some command was given as a full path, but not properly wrapped in quotes. Who did it? pydot says it did not do it, because it only called dot.bat:

['dot.bat', '-Tps', 'C:\Users\Jry\AppData\Local\Temp\tmppcmwp3ua'] return code: 1

I suspect that something inside the dot.bat file did it. The dot.bat file was created by conda during GraphViz installation. See line 37 of the conda recipe for GraphViz:

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

I don't know the syntax there exactly, but it looks like it is not wrapping the command in double quotes.

What to do next?

Judging by the error message and the mentioned line numbers, you must have been using a pydot version around 1.3.0. It is also clear that you installed it through conda. The official pydot releases never contained the line prog += '.bat'. There was prog += '.exe' (line 1833 of v1.3.0 for example), and it was conda who patched that line to prog += '.bat'. The conda-patch was dropped when pydot 1.4.0 started using .bat in Windows Anaconda environments itself (see #194. pydot/pydot-ng#52). So, first of all, you should try upgrading your Anaconda pydot and GraphViz packages.

Please report back if the latest versions still give you the same error indicating a problem with the space in D:\Program Files. If so, this should probably be reported at https://github.com/conda-forge/graphviz-feedstock next.

@peternowee
Copy link
Member

A user of another Python package reported the issue in conda-forge/graphviz-feedstock#43 recently. Also had a space character in the command path. I posted a possible solution there.

I think this issue here in pydot can be closed now.

@peternowee peternowee changed the title meet error, returncode 1, and assertionError 1 Graphviz executable not found due to space in path (meet error, returncode 1, and assertionError 1) Aug 27, 2020
@peternowee peternowee changed the title Graphviz executable not found due to space in path (meet error, returncode 1, and assertionError 1) Graphviz executable not found due to space in path (returncode 1, and assertionError 1) Aug 27, 2020
@peternowee
Copy link
Member

As mentioned in my previous comment, it seems that the root cause in this particular case (a space character in the Graphviz path) is with conda-forge/graphviz-feedstock#43 and should be solved there.

To anyone here looking for a solution to assertionError: 1, but not having a space character in the path of their Graphviz executable: assertionError: 1 is a very generic error message that can have many different causes. To find the specific cause of your error with pydot 1.4.1, see #203 (comment) and later comments and links to other issues there.

Improvements to the way pydot handles Graphviz errors are discussed in #218 (currently closed, but will be reopened soon).

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

No branches or pull requests

2 participants