[英]How to run Python script batch file with installed modules
I am trying to set up a batch file for a python script to run at a certain time every day.我正在尝试为 python 脚本设置一个批处理文件,以便每天在特定时间运行。 I set it up as such:我是这样设置的:
"C:\Users\payto\AppData\Local\Programs\Python\Python37-32\python.exe" "C:\Users\payto\OneDrive\Documents\MIPS_Platform\script.py" pause
Problem is, when the script is called from the batch file I receive an error saying that:问题是,当从批处理文件调用脚本时,我收到一条错误消息:
ModuleNotFoundError: No module named 'selenium' ModuleNotFoundError:没有名为“硒”的模块
Selenium is installed in the folder but is not recognized when called from the batch file. Selenium 安装在文件夹中,但从批处理文件调用时无法识别。 How do I get around this?我该如何解决这个问题?
Make sure you add 'C:\Users\payto\AppData\Local\Programs\Python\Python37-32\python.exe` to the system environment variable and then try the below确保将“C:\Users\payto\AppData\Local\Programs\Python\Python37-32\python.exe”添加到系统环境变量中,然后尝试以下操作
cmd /k python "C:\Users\payto\OneDrive\Documents\MIPS_Platform\script.py"
This will make sure the cmd window does not close after running the script.py这将确保 cmd window 在运行 script.py 后不会关闭
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.