Macã¨Emacsã®Pythonéçºç°å¢ã«ã¤ãã¦èª¿ã¹ã¦ã¿ã
Python使ããã¨å¹´åãé«ããªããããããªãã®ã§ã触ã£ã¦ãããã¨ã«ãã¾ããã
ã¨ããããã§ãã¾ãã¯Macä¸ã«éçºç°å¢ãæ´ãããã¨ã«ã
Pythonãã¼ã¸ã§ã³ç®¡ç
Macã¯æ¨æºã§Pythonãã¤ã³ã¹ãã¼ã«ããã¦ãããã®ã®ããã®ãã¼ã¸ã§ã³ã¯2.7ç³»ãï¼El Capitanã§ã¯2.7.11ãå ¥ã£ã¦ãã¾ããï¼
ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¯ä»ã®æç¹ã§3.5ã¾ã§ä¸ãã£ã¦ãããã®ã®ãã©ããã2.7ç³»ãã¾ã ã¾ã ç¾å½¹ãªãããªã®ã§ãç¨éã«å¿ãã¦åãæ¿ããããããã«ããã¼ã¸ã§ã³ç®¡çãã¼ã«ãå°å ¥ãã¦ãããã¨ã«ã
NodeãRubyãªã©ã®ãã¼ã¸ã§ã³ç®¡çã«anyenvã使ã£ã¦ããã®ã§ããã®æµãã§pyenvã使ãã¾ãã
$ anyenv install pyenv $ exec $SHELL -l $ pyenv install 3.5.1
ããã§3.xç³»ã触ã£ã¦ã¿ããã¨ãã«åãæ¿ãããã¾ãã
$ pyenv global 3.5.1 $ python --version Python 3.5.1 $ pyenv global system $ python --version Python 2.7.11
Pythonçéã§ã¯ãç°ãªããã¼ã¸ã§ã³ã®Pythonãæ±ãã¨ãã«virtualenvãªãä»çµã¿ãªã©ãããã¿ãããªã®ã§ããã¡ããã¤ã³ã¹ãã¼ã«ãã¦ããã
$ pip install virtualenv
Pythonããã±ã¼ã¸ç®¡ç
Node.jsã§è¨ãã¨ããã®npmã®ãããªããã±ã¼ã¸ç®¡çãã¼ã«ã¨ãã¦ã¯ã pip
ãããã¡ã¯ããªæ¨¡æ§ã
以åã¯å¥éã¤ã³ã¹ãã¼ã«ãå¿ è¦ã ã£ãããã§ãããEl Capitanä¸ã®Pyhtonã«ã¯pipãããªã¤ã³ã¹ãã¼ã«ããã¦ããã®ã§ããã®ã¾ã¾å©ç¨ã§ãã¾ãã
ãã¨ã§ä½¿ããããªæ©è½ã¨ãã¦ãBrewfileãªã©ã®ããã«å¿ è¦ãªããã±ã¼ã¸ã®ãªã¹ããç¨æãã¦ããã¦ãããããä¸æ¬ãã¦ã¤ã³ã¹ãã¼ã«ããæ©è½ãããã¿ããã
$ pip freeze > Pyfile $ pip install -r Pyfile
ããã使ãã°ãèªåã®ç°å¢æ§ç¯ãªãã¸ã㪠ã«ç°¡åã«å«ããããããªã¨æã£ãã®ã§ãããã¡ãã£ã¨è©¦ãã¦ã¿ãã¨ãããHomebrewãªã©ã§å ¥ãã¦ãã¾ã£ã¦ããPythonç³»ã®ãã¼ã«ãªã©ãå«ã¾ãã¦ãã¾ã£ã¦ããã®ã§ããã®ã¾ã¾ã ã¨äºé管çã®ãããªç¶æ ã«ãªãããã
å½é¢ã¯ pip install
ãç¾
åããã·ã§ã«ã¹ã¯ãªããã§ç®¡çãã¦ããã¦ãPythonæ´»ç¨ãããªãæ¹ãã¦æ¤è¨ãããã¨ã«ã
Emacsç¨éçºç°å¢
èªåã®ã¡ã¤ã³ã¨ãã£ã¿ã§ããEmacsã§ã®éçºç°å¢ã«ã¤ãã¦ã
ã¡ã¸ã£ã¼ã¢ã¼ã
Pythonç¨ã®ã¡ã¸ã£ã¼ã¢ã¼ãã¨ãã¦ã¯ãã©ããã2種é¡ãããããã
- python.el - Emacsæ¨æºã§ä»ãã¦ãããã®
- python-mode-devs/python-mode - ã³ãã¥ããã£ã«ãã£ã¦éçºããã¦ãããã®
ãããpython.elå´ã«python-modeã®æ©è½ãåãè¾¼ãã§ãããããªè¨ç»ãããããã§ããããããã£ãæå³ã§python-modeã®æ¹ãæ´»çºã«éçºããã¦ãããããªã®ã§ããã¡ããæ¡ç¨ãããã¨ã«ãã¾ããã
MELPAã§å
¬éããã¦ããã®ã§ list-packages
ã§python-modeãé¸æãã¦ã¤ã³ã¹ãã¼ã«ã
ãã®ã¾ã¾ã§ã¯æ¨æºæ·»ä»ã®python.elãåªå ããã¦ãã¾ãããã ã£ãã®ã§ã以ä¸ã®è¨å®ã追å ã
(autoload 'python-mode "python-mode" "Python Mode." t) (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (add-to-list 'interpreter-mode-alist '("python" . python-mode))
ãªããè²ã ã§ããã¿ããã ãã©ãã²ã¨ã¾ãã¤ã³ã¹ãã¼ã«ãã¦ããã¦ã使ãæ¹ã¯åå¼·ããªããã¤ããã§è¡ãã
éç解æ
Pythonç¨ã®éç解æãã¼ã«ãæ¢ãã«å½ãããFlycheckã対å¿ãã¦ããªãã確èªãã¦ã¿ã¾ããã
Supported Languages â Flycheck 26-cvs documentation
Flycheckããµãã¼ããã¦ããPythonç¨ã®éç解æãã¼ã«ã¨ãã¦ã¯ãflake8ãPylintãPythonã®ã³ã³ãã¤ã©ã使ãpycompileãªã©ãããã¿ããã
- Python ã® Lint (ææ³ãã§ãã«) ã¾ã¨ã - flake8 + hacking ã使ã - - Qiita
- Pythonã®ã¹ã¿ã¤ã«ã¬ã¤ãã¨ãããå®ãããã®å種Lintã»è§£æãã¼ã«5種ã¾ã¨ãï¼ - SideCI Blog
ã¨ããããå®åç¯å²ãåºãããªå°è±¡ã®Pylintã使ããã¨ã«ãã¾ããã
ãã£ãã pip
ã§ã¤ã³ã¹ãã¼ã«ã
$ pip install pylint
è¨å®ãã¡ã¤ã«ã¯ä»¥ä¸ã®æ¹æ³ã§åæãã³ãã¬ã¼ããçæã§ãããããã
$ pylint --generate-rcfile > ~/.pylintrc
ã¨ããããä½ãéè¦ãªã®ãããããªãã®ã§ãã¾ãã¯ããã©ã«ãã§éç¨ãã¦ã¿ã¦ãé©å®ããã£ã¦ãããã¨ã«ã
軽ãæ¸ããã ãã§ãããã¨åºã¦ãã C0111
ã ã disable ã«è¿½å ã
ãªã¼ãã³ã³ããªã¼ã
ãªã¼ãã³ã³ããªã¼ãç³»ã¨ãã¦ã¯ãJedi ã¨ããEmacsç¨ã®ãªã¼ãã³ã³ããªã¼ããã¼ã«ã便å©ãªãããªã®ã§å°å ¥ã
ã¾ãã¯MELPAããjediãã¤ã³ã¹ãã¼ã«å¾ãinit.elã«è¨å®ã追å ã
(add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t)
ãã®å¾ãEmacsä¸ã§ M+x jedi:install-server
ãå®è¡ãã¾ãã
ãã®ã¨ããå
é¨çã«virtualenvã§Jediç¨ã®ç°å¢ãä½ãããã®ã§ãããèªåã®å ´å ~/.emacs.d/.python-environments/default
ã¨ããå ´æã«ä½ããã¦ãã¾ãã¾ããã
ããã§ãinit.elã« jedi:environment-root
ã追å ãã¦ãç°å¢ãä½ãããå
ãè¨å®ãã¾ããã
(setq jedi:environment-root "~/.emacs.d/var/jedi/env")
- Emacsã®Pythonç°å¢ãæ§ç¯ - è¨ç®ç©çå±ã®ç 究åå¿é²
- emacsã«jedi(pythonã®èªåè£å®ããã±ã¼ã¸)ãå°å ¥ãã話 - Qiita
åå¼·
æ¥æ¬èªã®ããã¥ã¡ã³ãã¨ãã¦ã¯ Python 2.7.x ããã¥ã¡ã³ã ãè¯ããããã
ãã®ä¸ã® Python ãã¥ã¼ããªã¢ã« ããããä¸éãæ¼ããããããããã»ãã ãªã³ã©ã¤ã³ ããã¥ã¡ã³ã ããã¯PDFã§ã®ãã¦ã³ãã¼ãã§ãããµã¤ãããã£ãã®ã§ãã¨ã¦ããããããã
Pythonãã¥ã¼ããªã¢ã« 第3ç
- ä½è : Guido van Rossum,鴨澤ç夫
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³
- çºå£²æ¥: 2016/03/24
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ãã®ååãå«ãããã°ãè¦ã