Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在pip安装后使用参数运行py文件_Python - Fatal编程技术网

Python 在pip安装后使用参数运行py文件

Python 在pip安装后使用参数运行py文件,python,Python,我想修改此工具以进行文本清理: 我在cloud9工作。当我通过以下方式安装此有用工具时: sudo pip3 install chapterize 然后在txt文件上运行它: chapterize 10004.txt --nochapters 它工作正常 但是当我从这里将chapterize.py复制到cloud9环境时: 并运行: 我收到以下错误: Traceback (most recent call last): File "chapterize.py", line 259, in

我想修改此工具以进行文本清理:

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

sudo pip3 install chapterize
然后在txt文件上运行它:

chapterize 10004.txt --nochapters
它工作正常 但是当我从这里将chapterize.py复制到cloud9环境时: 并运行:

我收到以下错误:

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

中的errors参数出现在Python 3中


尝试python3 chapterize.py 10004.txt-nochapters

您使用的Python版本与hashbang中指定的版本不同。试试蟒蛇3。。。。
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