最近、Kubuntu 12.04 ( iPython
、matplotlib
、numpy
、ipython-notebook
、 )ipython-qtconsole
にいくつかの Python パッケージをインストールしましpython-scipy
た。コマンドラインから python スクリプトを実行しようとすると ( ./script.py
)、python インタープリターにスローされます。
例:
user@machine:~/$ ./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
スクリプトを問題なく実行できます。
@アダム・ミハルシン:
#!/usr/bin/python
編集 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)
編集 3: 誤警報!
これは恥ずかしいです。関数で名前空間の問題が発生することを知っていたことがわかりましたhelp()
。に変更しましhelpMenu()
たが、名前を変更するのを忘れていました。
無駄な投稿で申し訳ありません。:(