2017-03-04 176 views
-3

我无法从cmd promt打开一个shell。 PIP的作品,我可以键入一些命令,但不断得到错误。python:无法打开文件'hello_world':[Errno 2]没有这样的文件或目录

Directory of C:\Python27 

03/03/2017 08:07 PM <DIR>   . 
03/03/2017 08:07 PM <DIR>   .. 
03/03/2017 07:23 PM <DIR>   DLLs 
03/03/2017 07:23 PM <DIR>   Doc 
03/03/2017 08:07 PM <DIR>   dojopython 
03/03/2017 07:23 PM <DIR>   include 
03/03/2017 07:52 PM <DIR>   Lib 
03/03/2017 07:23 PM <DIR>   libs 
05/23/2015 10:29 AM   38,584 LICENSE.txt 
05/23/2015 10:23 AM   418,960 NEWS.txt 
05/23/2015 09:44 AM   26,624 python.exe 
05/23/2015 09:44 AM   27,648 pythonw.exe 
05/10/2015 06:01 PM   53,986 README.txt 
03/03/2017 07:36 PM <DIR>   Scripts 
03/03/2017 07:23 PM <DIR>   tcl 
03/03/2017 07:23 PM <DIR>   Tools 
       5 File(s)  565,802 bytes 
       11 Dir(s) 183,884,189,696 bytes free 

C:\Python27>python # 
python: can't open file '#': [Errno 2] No such file or directory 
+0

你想做什么? – AJPennster

+0

只需键入'python',你的'hello_world'文件在哪里 – Bijoy

+0

C:\ Python27 \ dojopython>它不会让我打开它的错误以及通过python打开一个shell# –

回答

0

的语法是:

python <python script> 

考虑以下 - foo.py存在,但bar.py并不:

$ ls foo.py bar.py 
ls: bar.py: No such file or directory 
foo.py 
$ 

现在,这将引发相同作为您的错误:

$ python bar.py 
python: can't open file 'bar.py': [Errno 2] No such file or directory 
$ 

而这个作品:

$ python foo.py 
hello world! 
$ 

注:打字只是 '蟒蛇'(没有任何python脚本)将推出你加载Python解释器交互的shell。 另外,我上面的例子使用Unix环境,而你的是Windows。尽管如此,相同的语法仍适用。

相关问题