I am trying to compile python scripts using Node.js. The python scripts include some modules I have installed. My package manager for python is Anaconda, so I tried to suppl
I don't think you want to call the Anaconda prompt.
Just call python: python print('hello')
.
What happens on the command line if you call: Anaconda Prompt (Anaconda3) print('hello')
?
(This should be a comment, but I cannot comment.)
I suspect that this is because the Anaconda Prompt is just some weird shortcut that sets up some variables for cmd.exe
Yes, that's pretty much it. So, no I don't think you can call it as proposed. There is probably a way to manipulate the cmd.exe
manually to get it running like an Anaconda Prompt session, but instead I'd propose to try...
Not sure if this will work in Windows, but it might be possible to use conda run
to execute within the Conda environment. This was introduced (and still remains) as an experimental feature in Conda v4.6, with the express purpose of enabling one to run something inside a Conda environment without interactively having to activate it.
First, you should probably test that conda run
works on Windows. Let's assume your conda.exe
is located at
C:\Users\dream\Anaconda3\Scripts\conda.exe
Start a clean cmd.exe
session, where conda
is undefined (i.e., not Anaconda Prompt). Then try things like
C:\Users\dream\Anaconda3\Scripts\conda.exe run where python
or, if you have another env, say my_env
you can also do
C:\Users\dream\Anaconda3\Scripts\conda.exe run -n my_env where python
to verify that the Python interpreter that gets run is the one specified.
If the above works, then you should be able to do something like
var exec = require('child_process').exec;
exec('C:\Users\dream\Anaconda3\Scripts\conda.exe run python hello.py', ..callback)
Not sure if you'll need the shell specified in this case.