简体   繁体   English

Python 脚本没有从我的批处理文件中执行

[英]Python script is not executed from my batch file

I have written the following code within a .bat file, (to execute a python script):我在.bat文件中编写了以下代码(用于执行 python 脚本):

conda activate 
cd OneDrive - My path/Documenti/Python/Seguridad/Remote 
py Seguridad_Python.py

If I execute that command in cmd.exe, the python file is executed.如果我在 cmd.exe 中执行该命令,则会执行 python 文件。

But, if I run the .bat file with those commands, it opens the Command Prompt window, but does not execute the python script.但是,如果我使用这些命令运行.bat文件,它会打开命令提示符窗口,但不会执行 python 脚本。

Can someone help?有人可以帮忙吗?

I have also tried it with the next one, (everything in the same line), and it does the same.我也尝试过下一个(所有内容都在同一行中),并且效果相同。

C:\ProgramData\Anaconda3\python.exe C:\Users\------ MY PATH --------\\Documenti\Python\Seguridad\Remote\Seguridad_Python.python

Adding a call before was enough.之前添加一个call就足够了。

If I have the batch file and the python script at the same level, this was enough:如果我在同一级别有批处理文件和 python 脚本,这就足够了:

call conda activate 

call py Seguridad_Python.py

Maybe you can try as below.也许你可以尝试如下。 Specify the batch file extension in the command prompt.在命令提示符中指定批处理文件扩展名。 Once you hit enter, it invokes your python script and run the program一旦你按下回车键,它就会调用你的 python 脚本并运行程序

C:\Users\------ MY PATH --------\\Documenti\Python\Seguridad\Remote\xyz.bat

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

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