Python脚本不起作用,但Spyder和CMD

我正在使用Anaconda-spyder,我的脚本在spyder中运行良好,也可以从CMD运行它 但我无法使用Nodejs应用程序运行脚本

Nodejs的

const express = require('express');
const router = express.Router();
const {PythonShell} = require("python-shell");


router.get('/hi', (req, res, next)=> {
  console.log("here");

    PythonShell.run('pyt//home.py', {

        args: ['infoo']
      }, function (err, results) {   
        console.log("here2");
        if(results)
        { console.log(results);}
        if(err)
            { console.log(err);}
        });
      });

module.exports = router;

在python代码中,使用的库

import os
import sys
import tweepy,codecs
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt


import nltk
from textblob import Word
import six
import numpy as np
import pandas as pd
from os import path
from PIL import Image
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
from nltk.corpus import stopwords
from matplotlib.backends.backend_pdf import PdfPages

import time

并使用以下命令在home.py中获取argv参数

if __name__ == "__main__":    
    twt = sys.argv[1]   
    print("hi python")

当我运行服务器时,请与邮递员联系。控制台说

[nodemon] watching path(s): *.*
      [nodemon] watching extensions: js,mjs,json
      [nodemon] starting `node ./bin/www`
      here
      here2
      { Error: ModuleNotFoundError: No module named 'pandas'
          at PythonShell.parseError (C:\Users\username\Desktop\NodejsBitirme\node_modules\python-shell\index.js:258:21)
          at terminateIfNeeded (C:\Users\username\Desktop\NodejsBitirme\node_modules\python-shell\index.js:141:32)
          at ChildProcess.<anonymous> (C:\Users\username\Desktop\NodejsBitirme\node_modules\python-shell\index.js:133:13)
          at ChildProcess.emit (events.js:198:13)
          at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
          ----- Python Traceback -----
          File "pyt\home.py", line 9, in <module>

好像安装了libs问题。它从cmd开始工作。

评论