gpt4 book ai didi

python -latexmk : error: no such option: -d

转载 作者:太空宇宙 更新时间:2023-11-03 14:27:56 26 4
gpt4 key购买 nike

当我想运行 python 脚本时遇到错误:

错误如下:

enter image description here

代码如下:

#!/usr/bin/python
import subprocess
code_dir = "code"
title = "Stanford ACM-ICPC Team Notebook"

def get_sections():
sections = []
section_name = None
with open('contents.txt', 'r') as f:
for line in f:
if '#' in line: line = line[:line.find('#')]
line = line.strip()
if len(line) == 0: continue
if line[0] == '[':
section_name = line[1:-1]
subsections = []
if section_name is not None:
sections.append((section_name, subsections))
else:
tmp = line.split('\t', 1)
if len(tmp) == 1:
raise ValueError('Subsection parse error: %s' % line)
filename = tmp[0]
subsection_name = tmp[1]
if subsection_name is None:
raise ValueError('Subsection given without section')
subsections.append((filename, subsection_name))
return sections

def get_style(filename):
ext = filename.lower().split('.')[-1]
if ext in ['c', 'cc', 'cpp']:
return 'cpp'
elif ext in ['java']:
return 'java'
elif ext in ['py']:
return 'py'
else:
return 'txt'

# TODO: check if this is everything we need
def texify(s):
#s = s.replace('\'', '\\\'')
#s = s.replace('\"', '\\\"')
return s

def get_tex(sections):
tex = ''
for (section_name, subsections) in sections:
tex += '\\section{%s}\n' % texify(section_name)
for (filename, subsection_name) in subsections:
tex += '\\subsection{%s}\n' % texify(subsection_name)
tex += '\\raggedbottom\\lstinputlisting[style=%s]{%s/%s}\n' % (get_style(filename), code_dir, filename)
tex += '\\hrulefill\n'
tex += '\n'
return tex

if __name__ == "__main__":
sections = get_sections()
tex = get_tex(sections)
with open('contents.tex', 'w') as f:
f.write(tex)
latexmk_options = ["latexmk", "-pdf", "notebook.tex"]
subprocess.call(latexmk_options)

我已经尝试安装latexmk,但没有成功。你能帮我看看安装latexmk的详细说明吗?我已经用谷歌搜索了很多。对于版权而言,这甚至不是我的代码。它的代码来自 stanford acm自己做。现在我想用它来制作我自己的。

最佳答案

确保可以从命令行访问latexmk。您可以通过在命令行中输入 latexmk -version 来检查这一点。如果无法从命令行访问它,则需要将 Latexmk 路径添加到环境变量中。

如果未安装latexmk,请按照此link操作正确安装latexmk

我认为遵循这些步骤可能会解决您的问题。

关于 python -latexmk : error: no such option: -d,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47493344/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com