question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: PythonShell.run is not a function

See original GitHub issue

点击手机显示打开然后秒关闭。终端提示错误信息如下,求大神解答。

root@raspberrypi:~# node HomeKitAppleDeveloper/Core.js 
HomeKit Apple Developer starting...
Change: true
/root/HomeKitAppleDeveloper/accessories/HomeKitAppleDeveloper_accessory.js:82
            PythonShell.run('../project/open.py', function (err) {
                        ^

TypeError: PythonShell.run is not a function
    at onUpdate (/root/HomeKitAppleDeveloper/accessories/HomeKitAppleDeveloper_accessory.js:82:25)
    at Characteristic.<anonymous> (/root/HomeKitAppleDeveloper/lib/AccessoryLoader.js:164:7)
    at Characteristic.emit (events.js:182:13)
    at Characteristic.setValue (/root/HomeKitAppleDeveloper/lib/Characteristic.js:320:10)
    at Accessory.<anonymous> (/root/HomeKitAppleDeveloper/lib/Accessory.js:871:22)
    at Array.forEach (<anonymous>)
    at Accessory._handleSetCharacteristics (/root/HomeKitAppleDeveloper/lib/Accessory.js:811:8)
    at HAPServer.emit (events.js:182:13)
    at HAPServer._handleCharacteristics (/root/HomeKitAppleDeveloper/lib/HAPServer.js:972:10)
    at HAPServer.<anonymous> (/root/HomeKitAppleDeveloper/lib/HAPServer.js:209:39)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

31reactions
ykm11commented, Oct 11, 2018

You guys probably tried such like

const PythonShell = require('python-shell')
PythonShell.run('/PATH/TO/example.py', null, function (err, results) {
  if (err) throw err;
  console.log('finished');
  console.log(results);
});

I got a same error, so I changed a little.

const ps = require('python-shell')
ps.PythonShell.run('/PATH/TO/example.py', null, function (err, results) {
  if (err) throw err;
  console.log('finished');
  console.log(results);
});

It works.

0reactions
philacher95commented, Sep 11, 2019

@ykm11 … this works …but folks the problem is I think from the python file Path:

for mine, I did not state the path correctly. Please check your .py file path

Read more comments on GitHub >

github_iconTop Results From Across the Web

PythonShell.run is not a function · Issue #151 - GitHub
this error means that PythonShell is undefined. Are you trying to require python-shell by any chance? Or are you importing it?
Read more >
NodeJS and Python-Shell .run function doesn't print STDOUT
I can get prints by using pythonShell.on and pythonShell.end. The problem is that I can't send args with this method. Then I use...
Read more >
How to use the python-shell.run function in python-shell - Snyk
To help you get started, we've selected a few python-shell.run examples, based on popular ways it ... PythonShell.run(str, function(err) { if (!process.env.
Read more >
python-shell - npm
Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio. Latest version: 3.0.1, ...
Read more >
Run Python Script using PythonShell from Node.js
Conclusion. This is the simple implementation of a how-to run python script with Node. js which can be useful in situations where you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found