Using with virtualenv created with --system-site-packages
, system libraries are unresolved #132
Description
Working with a virtualenv (Py2.7 in this case) build --system-site-packages
and activated via direnv
, system libraries such as os
, are not found by lsp
and are marked as unresolved-import
. Interactive python can import them fine, and VS Code also seems happy, shows documentation etc..
To reproduce:
(for reference I put a testing emacs minimal lsp
init .el
I used below)
- Create virtualenv with
system-site-packages
, e.g.:
(mkdir -p ~/.virtualenvs && cd ~/virtualenvs && virtualenv --python=python2 --system-site-packages py2env`)
source ~/virtualenvs/py2env/bin/activate
cat > foo.py <<EOF
import os
os.path.join('foo')
EOF
emacs -q -l minimal-lsp-init.el foo.py
- observe
unresolved-import 'os'
messages, though sometimes they disappear until I make an edit to the file
Emacs version: 27.1
lsp-python-ms version 0.7.1
I tried to dig in a bit but didn't get far. I can tell you that lsp-python-ms--get-python-ver-and-syspath
returned paths
including /usr/lib/python2.7
etc. where os
lives, so that seemed in order to me.
For testing to isolate from my emacs config, I made this minimal use-package
init.el and ran emacs -q -l init.el foo.py
:
;; ============================ bootstrap packaging ============================
(require 'package)
(add-to-list 'package-archives
'("MELPA" . "https://melpa.org/packages/"))
(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure 't)
;; =============================================================================
(use-package lsp-mode
:ensure t
:diminish lsp-mode
:commands lsp
:init
;; https://emacs-lsp.github.io/lsp-mode/page/performance/ suggestions:
(setq gc-cons-threshold 100000000
read-process-output-max (* 1024 1024))
(use-package lsp-python-ms
:ensure t
:init (setq lsp-python-ms-auto-install-server t)))
Thank you for this package, and please let me know what investigation I can do or how I can help.