LoginSignup
0
1

More than 1 year has passed since last update.

Cygwin+EmacsでのPython実行

Posted at

Run python in Emacs with Cygwin in Windows

Windows10 の中で、Cygwin と Emacs で Python する

Windows x64 の Python を使う

インストールは説明不要

.emacs その1

パスの表現は各自の環境次第

(require 'python) # これを使うかはお好みだろう
(setq python-shell-interpreter "/cygdrive/c/Users/.../Python39/python.exe")

Your `python-shell-interpreter' doesn't seem to support readline

の警告を防ぐ

https://qiita.com/ignorant/items/50f8eb2852d0f0214659
の use-package python
で始まる設定を .emacs に追加する

C-cC-c で FileNotFoundError になる

No such file or directory: '/cygdrive/c/Users/...'
というエラーが出る
これはパスの形式が Windows Python とこの Cygwin で違うためみたい

python-shell--save-temp-file に手を加える

advice-add を filter-return で使い、return するパスを加工する。
一例として先頭の /cygdrive/c を除去する

(defun my-xxx (fpath)
(replace-regexp-in-string "/cygdrive/c" "" fpath))
(advice-add 'python-shell--save-temp-file :filter-return "'my-xxx)

Emacs/Cygwin からもアクセス可能にする

トリッキーだがシンボリックリンクで解決する
管理者権限で Cygwin (64) を起動し、

ln -s /cygdrive/c/Users /Users

これで、 /Users/... で始まるパス記述でアクセスできる

おまけ tkinter

なぜか from Tkinter import * ではだめで、
ModuleNotFoundError: No module named 'Tkinter'
となってしまう。
理由はわからないが tkinter と小文字にしたら問題が消えた。
使ったテストでは tkinter による Window を閉じてもプロンプトに戻らず、 
py の最後に quit() を加えて、プロセスを終えるようにした。

0
1
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
0
1