在PIP安装后运行带有参数的PY文件



我想修改此工具以进行文本清洁:https://github.com/jonathanreeve/chapterize

我在Cloud9中工作。当我安装此有用的工具时:

sudo pip3 install chapterize

然后在TXT文件上运行:

chapterize 10004.txt --nochapters

它没有错误但是,当我从这里复制章节。https://github.com/jonathanreeve/chapterize/blob/master/chapterize/chapterize.py并运行:

python chapterize.py 10004.txt --nochapters

我收到以下错误:

Traceback (most recent call last):
File "chapterize.py", line 259, in <module>
cli()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in 
__call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in 
 main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in 
invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in 
invoke
return callback(*args, **kwargs)
File "chapterize.py", line 32, in cli
bookObj = Book(book, nochapters, stats)
File "chapterize.py", line 38, in __init__
self.contents = self.getContents()
File "chapterize.py", line 60, in getContents
with open(self.filename, errors='ignore') as f:
TypeError: 'errors' is an invalid keyword argument for this function

怎么了?为什么我不能这样运行?我尚未以任何方式修改源代码。

您可能正在运行Python 2。

open()中的errors参数存在于Python 3。

尝试python3 chapterize.py 10004.txt --nochapters

最新更新