2016-07-11 12 views
0

からpygraphvizチャートを描画するときに、私はpygraphvizでチャートを生成しようとしていますPermissionError Jupyter

それはこのアナコンダのバージョンで私のマシン上で動作します:

Python 3.3.5 |Continuum Analytics, Inc.| (default, Jun 4 2015, 15:22:11) 

それはときPermissionErrorを返します。私は別のマシンの実行中からそれを実行します。

Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:17:45) 

コードは次のとおりです。

from IPython.display import SVG 
import pygraphviz as pgv 
from IPython.display import display 

G = pgv.AGraph(directed=True) 

G = pgv.AGraph(compound=True,directed=True) 

sub = G.add_subgraph(name='cluster_1', label='Restaurant Open', rank='same') 

sub.add_node('initial', label='') 
sub.add_node('Loitering') 
sub.add_edge('initial','Loitering') 

G.draw('/tmp/state.svg', prog='dot') 
display(SVG(fn)) 

例外は次のとおりです。

--------------------------------------------------------------------------- 
PermissionError       Traceback (most recent call last) 
<ipython-input-1-762f54aa869d> in <module>() 
    16 
    17 fn='state.svg' 
---> 18 G.draw('/tmp/state.svg', prog='dot') 
    19 display(SVG(fn)) 

/home/jon/miniconda3/lib/python3.5/site-packages/pygraphviz/agraph.py in draw(self, path, format, prog, args) 
    1472    args = ' '.join([args, "-T" + format]) 
    1473 
-> 1474   data = self._run_prog(prog, args) 
    1475 
    1476   if path is not None: 

/home/jon/miniconda3/lib/python3.5/site-packages/pygraphviz/agraph.py in _run_prog(self, prog, args) 
    1314        stdout=subprocess.PIPE, 
    1315        stderr=subprocess.PIPE, 
-> 1316        close_fds=False) 
    1317   (child_stdin, 
    1318   child_stdout, 

/home/jon/miniconda3/lib/python3.5/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) 
    948         c2pread, c2pwrite, 
    949         errread, errwrite, 
--> 950         restore_signals, start_new_session) 
    951   except: 
    952    # Cleanup if the child failed starting. 

/home/jon/miniconda3/lib/python3.5/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, restore_signals, start_new_session) 
    1542        else: 
    1543         err_msg += ': ' + repr(orig_executable) 
-> 1544      raise child_exception_type(errno_num, err_msg) 
    1545     raise child_exception_type(err_msg) 
    1546 

PermissionError: [Errno 13] Permission denied 

どのように私はこのエラーを解決することができますか?

答えて

0

他のマシンの/tmp/に書き込み権限がありますか?試してくださいtouch /tmp/state.svg。それが失敗すると、これはunixパーミッションの問題です。 chmod/tmp/フォルダには、所有するユーザー(おそらくroot)が必要です。あるいは、書き込み先のパスを変更してみてください。おそらくあなたのホームディレクトリ~/state.svgを使用してください。

+0

私はtouch/tmp/state.svgを試してみました。この問題を解決しようとすると、私はPyCharmとAnacondaを再インストールしましたが、別の問題が発生しました... – Ginger

+0

PycharmとAnacondaの再インストールを試みたときに問題が変わった:http://stackoverflow.com/questions/38321442/oserror-when -loading-shared-libraries-with-pygraphviz – Ginger