在pip install之后运行带有参数的py文件

时间:2017-05-29 19:12:45

标签: python

我想修改此工具以进行文字清理: https://github.com/JonathanReeve/chapterize

我在cloud9工作。当我通过以下方式安装这个有用的工具时:

sudo pip3 install chapterize

然后在txt文件上运行它:

chapterize 10004.txt --nochapters

它没有错误 但是当我从这里将chapterize.py复制到cloud9环境时: 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

有什么问题?为什么我不能这样运行呢?我没有以任何方式修改源代码..

1 个答案:

答案 0 :(得分:1)

您可能正在运行Python 2.

{3}中的location参数出现在Python 3中。

尝试errors

相关问题