Python虚拟环境搭建
一、使用Python直接搭建虚拟环境
Archlinux
搭建:
python -m venv /*venvname*/
进入:
source venvname/bin/activate
在当前虚拟环境安装插件:
pip install /*appname*/ pip install setuptools(3.12之后版本必需)
退出:
deactivate
Windows
- 下载安装windows版python
- 下载安装Git for Windows
用git bash创建虚拟环境
python -m venv d:/PythonProject
安装插件
source d:/PythonProject/Scripts/activate pip install setuptools pip install jedi pip install flake8 pip install autopep8
二、Emacs设置
;; ==========python-mode========== (use-package python :mode ("\\.py\\'" . python-mode) :interpreter ("python" . python-mode) :bind ([f2] . elpy-shell-send-region-or-buffer) :config (message "Loading Python-mode...DONE") ) ;; ==========elpy========== (use-package elpy :ensure t :defer t :init (advice-add 'python-mode :before 'elpy-enable) ;; :hook ;; (python-mode . elpy-mode) :config (cond ((eq system-type 'gnu/linux) (pyvenv-activate "~/python/") (setq elpy-rpc-virtualenv-path 'current)) ((eq system-type 'windows-nt) (pyvenv-activate "D:/PythonProject/") (setq explicit-shell-file-name "C:/Program Files/Git/usr/bin/bash.exe" shell-file-name "bash.exe" python-shell-interpreter "python" elpy-rpc-virtualenv-path 'current elpy-rpc-python-command "D:/PythonProject/Scripts/python.exe"))) (message "Loading Elpy...DONE") )