Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/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
Node.js中的python shell不执行python脚本_Python_Node.js - Fatal编程技术网

Node.js中的python shell不执行python脚本

Node.js中的python shell不执行python脚本,python,node.js,Python,Node.js,我正在努力学习JavaScript。以前是用Python编写代码的。我喜欢将一些Python程序链接到Node.js中运行。使用python shell中的代码运行我的python脚本,但遇到了以下错误,我甚至无法理解: /Users/cadellteng/AtomProjects/useSpawn/node_modules/python-shell/index.js:217 return callback(err);

我正在努力学习JavaScript。以前是用Python编写代码的。我喜欢将一些Python程序链接到Node.js中运行。使用python shell中的代码运行我的python脚本,但遇到了以下错误,我甚至无法理解:

/Users/cadellteng/AtomProjects/useSpawn/node_modules/python-shell/index.js:217
                return callback(err);
                       ^

TypeError: callback is not a function
    at PythonShell._endCallback (/Users/cadellteng/AtomProjects/useSpawn/node_modules/python-shell/index.js:217:24)
    at terminateIfNeeded (/Users/cadellteng/AtomProjects/useSpawn/node_modules/python-shell/index.js:158:39)
    at ChildProcess.<anonymous> (/Users/cadellteng/AtomProjects/useSpawn/node_modules/python-shell/index.js:131:13)
    at ChildProcess.emit (events.js:316:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
你好,派伊

name = input('What is your name?\n>>> ') # John Doe
print('Hello '+ name +'!') # expects output as 'Hello John Doe!'
我试图将python放在
main()
中,但它似乎不起作用

我相信python脚本可以工作,因为当我从终端执行它时,它执行得很好。

请看

PythonShell.run
的参数是脚本名、选项对象和回调。所以回调是第三个参数

在您的情况下,您将在选项应该位于的位置传递回调。第三个参数仍然是未定义的,实际上它不是一个函数

name = input('What is your name?\n>>> ') # John Doe
print('Hello '+ name +'!') # expects output as 'Hello John Doe!'