[英]How do I activate python anaconda and run script from regular command prompt in Windows 10
I am trying to create an automated job to navigate to a network share and from there to run a Python script but permissions are a little wonky. 我正在尝试创建一个自动化作业,以导航到网络共享,然后从那里运行Python脚本,但是权限有些许问题。 If I start python first, it can't find the share.
如果我先启动python,则找不到共享。 However, I found that if I start an Anaconda prompt first, it can navigate to the share and execute no problem.
但是,我发现,如果我首先启动Anaconda提示符,它可以导航到共享并执行没有问题。 Here is the sequence of commands in a batch file:
这是批处理文件中的命令序列:
z:
CD Python
python ImportTool.py LocalCommands.txt
Unless there is a way to call an anaconda prompt directly from Task Scheduler, I figured I would need to add a line to the batch file to convert the command prompt to an Anaconda prompt. 除非可以直接从Task Scheduler调用anaconda提示符,否则我认为我需要在批处理文件中添加一行,以将命令提示符转换为Anaconda提示符。 This works:
这有效:
C:\ProgramData\Anaconda3\Scripts\activate.bat
The problem is once this runs, it ends the batch so the other commands don't run. 问题是一旦运行,它将结束批处理,因此其他命令将不会运行。 From the new command prompt if I call the remaining lines in another batch file it works but that means a second call.
在新命令提示符下,如果我在另一个批处理文件中调用其余行,则该行有效,但这意味着第二次调用。 This has to work in a single batch as a schedule job.
这必须作为计划工作单批处理。
So my question is, how can I modify my batch file to get my anaconda prompt and still be able to run the remaining commands without a second call? 所以我的问题是,如何修改我的批处理文件以得到anaconda提示,并且仍然能够运行其余命令而无需再次调用? TIA
TIA
I dug through the various calls. 我浏览了各种电话。 For some reason calling the conda.exe app is what throws off the batch execution.
由于某些原因,调用conda.exe应用程序会导致批处理执行失败。 It isn't necessary to call, however, if you add all the necessary paths for anaconda.
但是,如果您添加了蟒蛇的所有必需路径,则不必调用。 My final batch file looks like this:
我的最终批处理文件如下所示:
SET PATH=C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\bin;C:\ProgramData\Anaconda3\condabin;%PATH%
z:
CD Python
python ImportTool.py LocalCommands.txt
That does the job 做到了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.