简体   繁体   English

python 脚本执行中断

[英]python script execution broken

So, running in PowerShell I can normally execute scripts by either typing the name of the script (ie bob.py) or by invoking python and the script name (ie "python bob.py"), as long as bob.py is on my PATH.因此,在 PowerShell 中运行我通常可以通过键入脚本名称(即 bob.py)或调用 python 和脚本名称(即“python bob.py”)来执行脚本,只要 bob.py 处于打开状态我自己的路。 Starting today, the second method no longer works.从今天开始,第二种方法不再有效。 I can still type the name of the script directly (bob.py) but typing "python bob.py" results in a FileNotFound error.我仍然可以直接键入脚本的名称 (bob.py),但键入“python bob.py”会导致 FileNotFound 错误。 Python and bob.py are both on my PATH. Python 和 bob.py 都在我的路径上。

My question: why did this start happening?我的问题:为什么会发生这种情况? How do I fix it?我如何解决它?

Thanks in advance.提前致谢。

You can do the following:您可以执行以下操作:

  1. Type the directory path of the python file.键入 python 文件的目录路径。
python "C:\Users\test.py"
  1. use cd command to open powershell in that directory.使用cd命令在该目录中打开 powershell。
cd 'folder_path' 
python test.py

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

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