2016-10-14 7 views
2

私はちょうどPylatexを使用してpdfファイルを生成したいと思います。私は基本的な例を見て、スクリプトを再実行するが、エラーが発生した:OSError:[Errno 2]そのようなファイルやディレクトリはありません。ここでPDFファイルを生成する際のPylatexエラー - そのようなファイルまたはディレクトリがありません

は私のスクリプトです:

import sys 
from pylatex import Document, Section, Subsection, Command 
from pylatex.utils import italic, NoEscape 


def fill_document(doc): 
    """Add a section, a subsection and some text to the document. 
    :param doc: the document 
    :type doc: :class:`pylatex.document.Document` instance 
    """ 
    with doc.create(Section('A section')): 
     doc.append('Some regular text and some ') 
     doc.append(italic('italic text. ')) 

     with doc.create(Subsection('A subsection')): 
      doc.append('Also some crazy characters: $&#{}') 


if __name__ == '__main__': 
    reload(sys) 
    sys.setdefaultencoding('utf8') 
    # Basic document 
    doc = Document() 
    fill_document(doc) 

    doc.generate_pdf("full") 
    doc.generate_tex() 

とエラー:

Traceback (most recent call last): 
    File "/Users/code/Test Generator/Generate.py", line 34, in <module> 
    doc.generate_pdf("full") 
    File "/Library/Python/2.7/site-packages/pylatex/document.py", line 227, in generate_pdf 
    raise(os_error) 
OSError: [Errno 2] No such file or directory 

誰かが私を助けることができますか? :-Dありがとう。エラー周りのコードに基づいて

+0

私は同じ問題を抱えていました。解決策はありますか? –

答えて

2

は、あなたはおそらく、ラテックスコンパイラを逃している:

compilers = (
    ('latexmk', latexmk_args), 
    ('pdflatex', []) 
) 

はこれをやってみます:pythonを実行しているときに

apt-get install latexmk 
0

は、PATHにpdflatexをコマンドですスクリプト?そして、 が本当にあなたがtexliveをインストールしたことを本当に確信していて、それでもまだ動作しないなら、latexmkもインストールしてみてください。

私は同じ問題を抱えていましたが、あなたはtexliveがインストールされているとみなしてPATHを設定します。

私の場合、問題はPATHでした。 Flaskを使ってWebサイトを運営していました。サービスとしてuWsgiを使用してホスティングしていましたが、PATHは自分のvirtualenvで設定されていました。

だから私は、追加の固定:怒鳴る見て、働いていた "の/ usr/binが":

[Unit] 
Description=uWSGI instance to serve myproject 
After=network.target 

[Service] 
User=www-data 
Group=www-data 
WorkingDirectory=/sites/simapp 
Environment="PATH=/env/flask3/bin:/usr/bin" 
ExecStart=/env/flask3/bin/uwsgi --ini /sites/simapp/simapp.ini 

[Install] 
WantedBy=multi-user.target 
関連する問題