2013년 7월 16일 화요일

emacs python할때 현재 폴더에 있는 모듈을 불러오지 못할때.

http://stackoverflow.com/questions/2658475/python-mode-import-problem

.emace.d/init.el에

(defun python-reinstate-current-directory ()
  "When running Python, add the current directory ('') to the head of sys.path.
For reasons unexplained, run-python passes arguments to the
interpreter that explicitly remove '' from sys.path. This means
that, for example, using `python-send-buffer' in a buffer
visiting a module's code will fail to find other modules in the
same directory.

Adding this function to `inferior-python-mode-hook' reinstates
the current directory in Python's search path."
  (python-send-string "sys.path[0:0] = ['']"))

(add-hook 'inferior-python-mode-hook 'python-reinstate-current-directory)

위와 같이 추가

댓글 없음:

댓글 쓰기