简体   繁体   English

如何在python-shell中更改pythonPath?

[英]How to change pythonPath in python-shell?

I'm trying to write python app (for study project) using Electron (because I want to make my app look nice, so I am learning javascript, html and css too). 我正在尝试使用Electron编写python应用程序(用于研究项目)(因为我想使我的应用程序看起来不错,所以我也在学习javascript,html和css)。 I try to use python-shell to run python script from javascript. 我尝试使用python-shell从javascript运行python脚本。 I installed python into the folder with my project and want to use interpreter for the project from this folder, but nodejs uses the interpreter from another folder Anaconda3 (which was installed several months before and is used for other projects). 我在项目的文件夹中安装了python,并希望使用此文件夹中的项目的解释器,但是nodejs使用另一个文件夹Anaconda3(该文件夹在几个月前已安装,并用于其他项目)中的解释器。 I try to change path to interpreter using options={pythonPath: 'relative path to python.exe'} in python-shell constructor in .js files, but that just doesn't change anything. 我尝试在.js文件的python-shell构造函数中使用options = {pythonPath:'python.exe的相对路径'}更改解释器的路径,但这只是不改变任何内容。 What can I do to change path to interpreter that I need? 我该怎么做才能更改所需的口译员的路径? Thank you. 谢谢。 My OS is Windows. 我的操作系统是Windows。

    var options = {
  mode: 'text',
  pythonPath: 'python'
  };
let {PythonShell} = require('python-shell',options)

重新启动计算机后,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM