2012-04-27 27 views
0

私は最近、Kubuntuの12.04(iPythonmatplotlibnumpyipython-notebookipython-qtconsolepython-scipy)上のいくつかのPythonパッケージをインストールしたを開いています。今私がコマンドライン(./script.py)からPythonスクリプトを実行しようとすると、私はPythonインタプリタに投げ込まれます。Pythonスクリプトは、Python 2.7インタプリタ

例:

[email protected]:~/$ ./script.py 

Welcome to Python 2.7! This is the online help utility. 

If this is your first time using Python, you should definitely check out 
the tutorial on the Internet at http://docs.python.org/tutorial/. 

Enter the name of any module, keyword, or topic to get help on writing 
Python programs and using Python modules. To quit this help utility and 
return to the interpreter, just type "quit". 

To get a list of available modules, keywords, or topics, type "modules", 
"keywords", or "topics". Each module also comes with a one-line summary 
of what it does; to list the modules whose summaries contain a given word 
such as "spam", type "modules spam". 

help> 

ですが、なぜでしょうか?

これを停止するにはどうすればよいですか?

iPythonを削除する以外に選択肢はありますか?

編集: スクリプトはPythonモジュールです。私はそれがそれと何か関係があるかどうかわかりません。私は単純なhello worldスクリプトを実行することができます。

@Adam Mihalcin: #!/usr/bin/python

EDIT 2: それはこのようになりますがiPythonとは関係ありません。私はiPythonを削除しましたが、私はまだこの問題にぶち当たっています。ファイルの内容は次のとおりです。 (これは私のPythonのほとんどのファイルで何が起こっている)

#!/usr/bin/python 

# Import libraries 
import sys 
import subprocess 

def createCommand(project): 
    # Create the basic command 
    command = "git clone " + project 

    subprocess.call(command, shell = True) 

    return 0 

def helpMenu(): 

    return 0; 

def validateInput(user_input): 
    # validity key 
    valid = 0 

    if (len(user_input) < 3): 
     help() 
     return 1 

    if (user_input[1] == '-cl'): 
     if (len(user_input) == 3): 
      valid = 1 
      return 0 

    if (valid == 0): 
     help() 
     return 1 

def main(user_input): 
    # Validate inputs 
    failure = validateInput(user_input) 

    # Return if there was a failure  
    if (failure == 1): 
     return 1; 

    # Create the git commands   
    failure = createCommand(user_input[2]) 

    # Return if there was a failure  
    if (failure == 1): 
     return 1; 

    return 0; 

if (__name__ == '__main__'): 
    main(sys.argv) 

EDIT 3: 誤警報!

これは恥ずかしいです。私のhelp()関数で名前空間の問題に遭遇することが分かっていたことが分かりました。私はhelpMenu()に変更しましたが、呼び出された場所を変更するのを忘れました。

無駄な投稿には申し訳ありません。 :(

+1

「script.py」の最初の行([shebang line](http://en.wikipedia.org/wiki/Shebang_(Unix)))を投稿することができますか? ? –

+0

あなたは、通常のPythonインタプリタを使用していない理由はありますか? – Raceimaztion

+0

は 'は/ usr/binに/ python'通常のインタプリタではないですか?それとも、' Pythonの2.7について話している!これは、オンラインヘルプutility.'の一部であり、あなたが後者について話しているなら、私はこれを使うつもりはありませんでした。 – Rico

答えて

0

これは恥ずかしいです。それは私が私が私の助け()関数で名前空間の問題に実行するつもりだった知っていた。私はhelpMenu()にそれを変更したが、それが呼ばれています場所を変更するのを忘れて判明した。

I :