我已阅读有关此主题的每个问题,但仍无法解决此问题。最令人沮丧的是,这不是在我的一个脚本中发生的,而是在第三方库(Naked)中发生的。这是我的代码:
import Naked.toolshed.shell as shell
#skip a few lines
respondedSuccessfully = shell.execute_js("notifications.js", token)
这是Naked的execute_js
功能:
import subprocess
#skip a few lines
def execute_js(file_path, arguments=""):
try:
if len(arguments) > 0:
js_command = 'node ' + file_path + " " + arguments
else:
js_command = 'node ' + file_path
return execute(js_command) # return result of execute() of node.js file
except Exception as e:
if DEBUG_FLAG:
sys.stderr.write("Naked Framework Error: unable to run the shell command with the run_js() function (Naked.toolshed.shell.py).")
raise e
到目前为止,这么好。以下是它调用的execute()
函数:
def execute(command):
try:
response = subprocess.call(command, shell=True)
if response == 0:
return True
else:
return False
except subprocess.CalledProcessError as cpe:
try:
sys.stderr.write(cpe.output)
except TypeError as te:
sys.stderr.write(str(cpe.output))
except Exception as e:
if DEBUG_FLAG:
sys.stderr.write("Naked Framework Error: unable to run the shell command with the execute() function (Naked.toolshed.shell.py).")
raise e
当我执行我的代码时,它会抛出以下错误:
AttributeError: 'module' object has no attribute 'CalledProcessError'
我没有名为" subprocess"的文件,并逐个执行这些行。我很难过。 Here是裸体图书馆。
提前谢谢。