简体   繁体   English

如何在Windows 10中从常规命令提示符处激活python anaconda并运行脚本

[英]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.

相关问题 如何在命令提示符Windows 10中运行python脚本 - How to run python script in Command Prompt Windows 10 在 Anaconda 命令提示符中运行 Python 脚本的 Windows 快捷方式 - Windows Shortcut to Run Python Script in Anaconda Command Prompt 如何从 Windows 10 命令提示符激活虚拟环境 - How to activate virtual environment from Windows 10 command prompt 如何在 Windows 7 的命令提示符中运行 Python 程序? - How do I run a Python program in the Command Prompt in Windows 7? 如何在Windows10中从bash提示符运行python'__main__'程序文件? - How do I run python '__main__' program file from bash prompt in Windows10? 如何在 pypy3 上运行 python 脚本而不使用 windows 10 上的命令行? - How do I run a python script on pypy3 without using the command line on windows 10? 如何从 windows 命令提示符在虚拟环境中运行 python 程序? - How do I run a python program in a virtual environment from windows command prompt? 如何获取 python 脚本以在 Windows (10) 中运行命令 shell (10),它在程序特定位置打开? - How do I get a python script to run a command shell in Windows (10) where it opens in a program specific location? 如何在Windows 10中的命令提示符(cmd)中从带有子进程模块的python脚本编写命令 - how to write command in command prompt (cmd) in windows 10 from python script with subprocess module Python 模块请求在 anaconda 提示符下工作但不在 Windows 10 命令行中工作 - Python module requests working in anaconda prompt but not in windows 10 command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM