简体   繁体   English

如何在 Windows/Anaconda 终端上运行 .py 文件?

[英]How to run .py files on Windows/Anaconda terminal?

So I installed Anaconda on my computer, and use Jupiter notebook to write a script.于是我在我的电脑上安装了Anaconda,并用Jupiter notebook写了一个脚本。

I have some.py files I want to run from Windows or Anaconda Terminal, just out of curiosity.我有一些.py 文件,我想从 Windows 或 Anaconda 终端运行,只是出于好奇。

Here are the error message I got -这是我收到的错误消息 -

C:\Users\xxx\Documents>python ex1.py 'python' is not recognized as an internal or external command, operable program or batch file. C:\Users\xxx\Documents>python ex1.py 'python' 不是内部或外部命令、可运行程序或批处理文件。

Is there a way that I can run python on Windows without messing up the path?有没有办法可以在 Windows 上运行 python 而不会弄乱路径?

I guess you are using Command prompt to parse python files.我猜您正在使用命令提示符来解析 python 文件。

  • Open Anaconda Prompt ,打开Anaconda 提示
  • navigate to the folder containing your python files cd c:\path\to\python\folder导航到包含 python 文件的文件夹cd c:\path\to\python\folder
  • execute using python ex1.py where ex1.py is your filename使用python ex1.py执行,其中ex1.py是您的文件名

in the anaconda terminal在 anaconda 端子

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

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