亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

npm python-shell 不適用于電子

npm python-shell 不適用于電子

收到一只叮咚 2021-07-09 17:02:14
我正在嘗試使用 npm 的 python-shell 包將 python 腳本與 Electron 應用程序鏈接。條件是每當我單擊按鈕時執行腳本。所以,假設我的目錄包含:main.js (electron file)index.js (my script)index.htmlmain.py在 index.js 中,我編寫了以下代碼來導入 python-shell 并執行 main.py 腳本:function get_input() {    var python = require("python-shell")    var path = require("path")    var options = {        scriptPath: path.join(__dirname, './python/')    }    var weather = new python('main.py', options);    weather.on('message', function (message) {        console.log(message);    })}在 index.html 中,我創建了一個按鈕標簽來在點擊時運行這個函數:<button onclick="get_input()">Go!</button>在 main.py 中,我現在所做的就是打印“hello”?,F在,當我運行時,npm start我收到以下錯誤:有誰知道為什么這不起作用?我看了很多關于 Electron 的文章,它們都做同樣的事情,而且很有效。如果我遺漏了什么,請告訴我。
查看完整描述

1 回答

?
寶慕林4294392

TA貢獻2021條經驗 獲得超8個贊

更改var python = require("python-shell")



const {PythonShell} = require("python-shell");


查看完整回答
反對 回復 2021-07-13
  • 1 回答
  • 0 關注
  • 364 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號