无法从命令提示符打开Python程序
我在命令提示符下运行 .py 文件时遇到了这个问题:
C:\users\ocean>python helloworld.py
python: can't open file 'helloworld.py': [Errno 2] No such file or directory
环境变量已经设置为 ;C\python27 和 ;C\python32(没错,我同时在用这两个版本的 Python)。
我需要设置一个新的变量吗?我该怎么做?我用的是 Windows 7,之前连 'python' 都无法识别,搞得我很头疼。
补充:C:\users\oceans 里没有我的 Python 文件夹。有没有办法重定向目录,这样我就不需要把所有的 Python 文件移动到 oceans 文件夹里?
1 个回答
2
你需要选择以下两种方式之一:
python c:\path\to\the\file.py
或者
cd c:\path\to\the
python file.py