LoginSignup
33
22

More than 5 years have passed since last update.

Git bash 上から Python インタプリタを起動する

Last updated at Posted at 2016-03-06

Git for Windows を 1.9.5 から 2.7.2 にアップデートしたところ、python が...

pythonインタプリタが起動しない

C:\Python27 にPATHを通した状態で、Git Bash を起動する。
おもむろにpythonと叩くと..

$ python

... 返ってこない。

対策

以下のような alias を ~/.bashrc あたりに書いておく。
(そして source ~/.bashrc して読み込ませる)

bash
alias python='winpty python.exe'

解決

$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

起動するようになった。

その他

ちなみに、ipython を pip で install したらいつも間にか alias に下記が追加されていた。

alias ipython='winpty ipython.exe'

調べたところ、下記のような仕掛けがされている。Git 2.5.2(2) からの様子。
vscode-alias.PNG
これは、/etc/profile.d/aliases.sh に記載されている。コマンドにパスが通っていたらaliasする仕組みだ。

33
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
22