diff --git a/lisp/prog-python.el b/lisp/prog-python.el
index ad7f78562c664b0301a2c58cb2a0cbda02050b7e..3fb5bbfd42da594b480d7dce8b8ee83164d9e659 100644
--- a/lisp/prog-python.el
+++ b/lisp/prog-python.el
@@ -1,35 +1,51 @@
+;;; prog-python.el --- Configuration for python.
+;;; Commentary:
 
 ;;; Code:
+(defvar python/pyvenv-modes nil)
 
-(defun python/pyenv-executable-find (command)
-  "Find executable taking pyenv shims into account."
-  ())
-(defun python/execute-file (args)
-  "Execute a python script in a shell."
-  (interactive "P")
-  (let ((universal-argument t)
-        (compile-command (format "%s %s")))))
+(defun python/pyvenv-set-local-virtualenv ()
+  "Set pyvenv virtualenv from \".venv\" by looking in parent directories."
+  (interactive)
+  (let ((root-path (locate-dominating-file default-directory ".venv")))
+    (when root-path
+      (let ((file-path (expand-file-name ".venv" root-path)))
+        (cond ((file-directory-p file-path)
+               (pyvenv-activate file-path)
+               (message "Activated local virtualenv"))
+              (t (message ".venv is not a directory")))))))
 
-(use-package importmagic
+(use-package python
   :defer t
-  :ensure t
-  :diminish importmagic-mode
-  :init
-  (add-hook 'python-mode-hook 'importmagic-mode))
+  :ensure nil
+  :after flycheck
+  :mode "\\.py\\'"
+  :custom
+  (python-indent-offset 4)
+  (flycheck-python-pycompile-executable "python3")
+  :config
+  (setq python-shell-interpreter "python3"))
 
-(use-package pipenv
-  :defer t
+(use-package lsp-pyright
   :ensure t
-  :init
-  (add-hook 'python-mode-hook #'pyvenv-tracking-mode))
+  :hook (python-mode . (lambda () (require 'lsp-pyright)))
+  :init (when (executable-find "python3")
+          (setq lsp-pyright-python-executable-cmd "python3")))
 
 (use-package yapfify
   :ensure t
   :defer t
   :hook (python-mode . yapf-mode))
 
-(use-package python
-  :defer t)
+(use-package pyvenv
+  :ensure t
+  :init
+  (add-hook 'python-mode-hook #'pyvenv-tracking-mode)
+  (add-to-list 'python/pyvenv-modes 'python-mode)
+  ;; Set for auto active virtual env
+  (dolist (m python/pyvenv-modes)
+    (add-hook (intern (format "%s-hook" m))
+              'python/pyvenv-set-local-virtualenv())))
 
 (provide 'prog-python)
 ;;; prog-python.el ends here