Why does draw() in pygraphviz/agraph not work on the server (but locally)?
I have a Python app using Pygraphviz that works fine locally, but on the server the draw
function throws an error. It happens in make_svg
. The following lines are the relevant part of the errors I get. (The full trail is here.)
File "/path/to/app/utils/make_svg.py", line 17, in make_svg
prog='dot'
File "/path/to/pygraphviz/agraph.py", line 1477, in draw
fh = self._get_fh(path, 'w+b')
File "/path/to/pygraphviz/agraph.py", line 1506, in _get_fh
fh = open(path, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'app/svg_files/nope.svg'
Logging type(g)
gives <class 'pygraphviz.agraph.AGraph'>
as expected.
I work in a virtualenv in a mod_wsgi 4.6.5/Python3.7
environment on a Webfaction server.
Locally I use a virtualenv with Python 3.5.
The version of Pygraphviz is 1.3.1.
(First I had 1.5 on the server. The error was exactly the same, except for the line numbers.)
What can I do?
The same error is described in this bug report from last year.
I don't get which directory I am supposed to create. svg_files
exists and has rights 777.
The draw
function at the end of make_svg
should create the SVG.
(And at the end of extract_coordinates_from_svg
the file is removed again.)
The file name is a hash created in connected_dag
(svg_name
).
python-3.x pygraphviz graph-drawing
add a comment |
I have a Python app using Pygraphviz that works fine locally, but on the server the draw
function throws an error. It happens in make_svg
. The following lines are the relevant part of the errors I get. (The full trail is here.)
File "/path/to/app/utils/make_svg.py", line 17, in make_svg
prog='dot'
File "/path/to/pygraphviz/agraph.py", line 1477, in draw
fh = self._get_fh(path, 'w+b')
File "/path/to/pygraphviz/agraph.py", line 1506, in _get_fh
fh = open(path, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'app/svg_files/nope.svg'
Logging type(g)
gives <class 'pygraphviz.agraph.AGraph'>
as expected.
I work in a virtualenv in a mod_wsgi 4.6.5/Python3.7
environment on a Webfaction server.
Locally I use a virtualenv with Python 3.5.
The version of Pygraphviz is 1.3.1.
(First I had 1.5 on the server. The error was exactly the same, except for the line numbers.)
What can I do?
The same error is described in this bug report from last year.
I don't get which directory I am supposed to create. svg_files
exists and has rights 777.
The draw
function at the end of make_svg
should create the SVG.
(And at the end of extract_coordinates_from_svg
the file is removed again.)
The file name is a hash created in connected_dag
(svg_name
).
python-3.x pygraphviz graph-drawing
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11
add a comment |
I have a Python app using Pygraphviz that works fine locally, but on the server the draw
function throws an error. It happens in make_svg
. The following lines are the relevant part of the errors I get. (The full trail is here.)
File "/path/to/app/utils/make_svg.py", line 17, in make_svg
prog='dot'
File "/path/to/pygraphviz/agraph.py", line 1477, in draw
fh = self._get_fh(path, 'w+b')
File "/path/to/pygraphviz/agraph.py", line 1506, in _get_fh
fh = open(path, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'app/svg_files/nope.svg'
Logging type(g)
gives <class 'pygraphviz.agraph.AGraph'>
as expected.
I work in a virtualenv in a mod_wsgi 4.6.5/Python3.7
environment on a Webfaction server.
Locally I use a virtualenv with Python 3.5.
The version of Pygraphviz is 1.3.1.
(First I had 1.5 on the server. The error was exactly the same, except for the line numbers.)
What can I do?
The same error is described in this bug report from last year.
I don't get which directory I am supposed to create. svg_files
exists and has rights 777.
The draw
function at the end of make_svg
should create the SVG.
(And at the end of extract_coordinates_from_svg
the file is removed again.)
The file name is a hash created in connected_dag
(svg_name
).
python-3.x pygraphviz graph-drawing
I have a Python app using Pygraphviz that works fine locally, but on the server the draw
function throws an error. It happens in make_svg
. The following lines are the relevant part of the errors I get. (The full trail is here.)
File "/path/to/app/utils/make_svg.py", line 17, in make_svg
prog='dot'
File "/path/to/pygraphviz/agraph.py", line 1477, in draw
fh = self._get_fh(path, 'w+b')
File "/path/to/pygraphviz/agraph.py", line 1506, in _get_fh
fh = open(path, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'app/svg_files/nope.svg'
Logging type(g)
gives <class 'pygraphviz.agraph.AGraph'>
as expected.
I work in a virtualenv in a mod_wsgi 4.6.5/Python3.7
environment on a Webfaction server.
Locally I use a virtualenv with Python 3.5.
The version of Pygraphviz is 1.3.1.
(First I had 1.5 on the server. The error was exactly the same, except for the line numbers.)
What can I do?
The same error is described in this bug report from last year.
I don't get which directory I am supposed to create. svg_files
exists and has rights 777.
The draw
function at the end of make_svg
should create the SVG.
(And at the end of extract_coordinates_from_svg
the file is removed again.)
The file name is a hash created in connected_dag
(svg_name
).
python-3.x pygraphviz graph-drawing
python-3.x pygraphviz graph-drawing
edited Nov 25 '18 at 19:27
Watchduck
asked Nov 24 '18 at 21:34
WatchduckWatchduck
4231517
4231517
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11
add a comment |
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11
add a comment |
1 Answer
1
active
oldest
votes
On the server app/svg_files
seems not to describe the same place as locally.
I defined the path unambiguously, and now it works.
file_path = '{grandparent}/svg_files/{name}.svg'.format(
grandparent=os.path.dirname(os.path.dirname(__file__)),
name=name
)
g.draw(file_path, prog='dot')
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462567%2fwhy-does-draw-in-pygraphviz-agraph-not-work-on-the-server-but-locally%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
On the server app/svg_files
seems not to describe the same place as locally.
I defined the path unambiguously, and now it works.
file_path = '{grandparent}/svg_files/{name}.svg'.format(
grandparent=os.path.dirname(os.path.dirname(__file__)),
name=name
)
g.draw(file_path, prog='dot')
add a comment |
On the server app/svg_files
seems not to describe the same place as locally.
I defined the path unambiguously, and now it works.
file_path = '{grandparent}/svg_files/{name}.svg'.format(
grandparent=os.path.dirname(os.path.dirname(__file__)),
name=name
)
g.draw(file_path, prog='dot')
add a comment |
On the server app/svg_files
seems not to describe the same place as locally.
I defined the path unambiguously, and now it works.
file_path = '{grandparent}/svg_files/{name}.svg'.format(
grandparent=os.path.dirname(os.path.dirname(__file__)),
name=name
)
g.draw(file_path, prog='dot')
On the server app/svg_files
seems not to describe the same place as locally.
I defined the path unambiguously, and now it works.
file_path = '{grandparent}/svg_files/{name}.svg'.format(
grandparent=os.path.dirname(os.path.dirname(__file__)),
name=name
)
g.draw(file_path, prog='dot')
edited Nov 25 '18 at 0:50
answered Nov 24 '18 at 22:57
WatchduckWatchduck
4231517
4231517
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462567%2fwhy-does-draw-in-pygraphviz-agraph-not-work-on-the-server-but-locally%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Upload the file nope.svg to app/svg_files/ on the server...
– cli_hlt
Nov 24 '18 at 21:53
The creation of this SVG on the server is what fails. I clarified that in the description.
– Watchduck
Nov 24 '18 at 22:11