microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
911 stars 131 forks source link

Python extension unable to find packages installed in sub directory #1118

Closed karrtikr closed 5 years ago

karrtikr commented 5 years ago

@potens1 commented on Tue May 21 2019

Environment data

Expected behaviour

The python extension should be able to use the virtualenv, including packages installed in dev mode

Actual behaviour

Errors about import of packages and errors about undefined variables

Screenshot from 2019-05-21 08-53-08

Screenshot from 2019-05-21 09-03-43

systemd package is not system wide installed, only in the virtualenv and it is found by the extension

Steps to reproduce:

  1. Create a package
  2. Define a function in the init.py of the package
  3. Install the package in the virtualenv with pip install -e (or pipenv install -e .)
  4. In another file, try to import the package

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - mypy##########
Starting Microsoft Python language server.
[Info  - 9:32:46 AM] GetCurrentSearchPaths /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python 
[Info  - 9:32:46 AM] Python search paths:
[Info  - 9:32:46 AM]     /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/lib/python3.7
[Info  - 9:32:46 AM]     /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/lib/python3.7/lib-dynload
[Info  - 9:32:46 AM]     /usr/lib64/python3.7
[Info  - 9:32:46 AM]     /usr/lib/python3.7
[Info  - 9:32:46 AM]     /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/lib/python3.7/site-packages
[Info  - 9:32:46 AM]     /home/ndp/sandbox/sandbox/src
[Info  - 9:32:46 AM] Configuration search paths:
[Info  - 9:32:46 AM] Microsoft Python Language Server version 0.2.82.0
[Info  - 9:32:46 AM] Initializing for /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/pytho

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Nothing relevant to me but... ``` [Violation] Added non-passive event listener to a scroll-blocking event. Consider marking event handler as 'passive' to make the page more responsive. See [V workbench.main.js:3272 [Extension Host] debugger listening on port 49928 workbench.main.js:4342 Overwriting grammar scope name to file mapping for scope source.yaml. Old grammar file: file:///home/ndp/.local/share/vscode/VSCode-linux-x64/resources/app/extensions/yaml/syntaxes/yaml.tmLanguage.json. New grammar file: file:///home/ndp/.vscode/extensions/redhat.vscode-yaml-0.4.0/syntaxes/yaml.tmLanguage.json workbench.main.js:4342 Overwriting grammar scope name to file mapping for scope source.jinja. Old grammar file: file:///home/ndp/.vscode/extensions/korekontrol.saltstack-0.0.5/syntaxes/jinja.json. New grammar file: file:///home/ndp/.vscode/extensions/wholroyd.jinja-0.0.8/syntaxes/jinja.json workbench.main.js:4342 Overwriting grammar scope name to file mapping for scope text.yaml.jinja. Old grammar file: file:///home/ndp/.vscode/extensions/korekontrol.saltstack-0.0.5/syntaxes/sls.json. New grammar file: file:///home/ndp/.vscode/extensions/wholroyd.jinja-0.0.8/syntaxes/jinja-yaml.json workbench.main.js:238 [Extension Host] (node:28399) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Create file systemwatcher with pattern */python workbench.main.js:238 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Register Intepreter Watcher, Class name = p, Arg 1: , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Build the workspace interpreter watcher, Class name = h, Arg 1: , Return Value: workbench.main.js:1469 [Violation] 'setTimeout' handler took 64ms [Violation] Forced reflow while executing JavaScript took 60ms workbench.main.js:3270 Extension Host workbench.main.js:3270 Debugger attached. workbench.main.js:238 [Extension Host] Python Extension: Rule = settings, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from settings workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, workbench.main.js:1401 WARN UNRESPONSIVE extension host, 'ms-python.python' took 95% of 234.641ms, saved PROFILE here: '/tmp/ndp/exthost-84f48e.cpuprofile' (3) [{…}, {…}, {…}] workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Failed to execute fetch Error: Command failed: git remote fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). at makeError (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:174:9) at module.exports.Promise.all.then.arr (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:278:16) at process._tickCallback (internal/process/next_tick.js:68:7) workbench.main.js:238 [Extension Host] Failed to execute fetch Error: Command failed: git remote fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). at makeError (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:174:9) at module.exports.Promise.all.then.arr (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:278:16) workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by CondaEnvFileService are of count 0 workbench.main.js:238w [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Failed to execute fetch Error: Command failed: git remote fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). at makeError (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:174:9) at module.exports.Promise.all.then.arr (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:278:16) at process._tickCallback (internal/process/next_tick.js:68:7) 3 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox 2 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox/src/sandbox/__init__.py 2 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox/src/sandbox/other.py workbench.main.js:238 [Extension Host] Failed to execute fetch Error: Command failed: git remote fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). at makeError (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:174:9) at module.exports.Promise.all.then.arr (/home/ndp/.vscode/extensions/fatihacet.gitlab-workflow-2.1.0/node_modules/execa/index.js:278:16) at process._tickCallback (internal/process/next_tick.js:68:7) 3 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by CondaEnvService are of count 0 workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by KnownPathsService are of count 51 2 workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by CurrentPathService are of count 6 workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by VirtualEnvService are of count 3 2 workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by WorkspaceVirtualEnvService are of count 223 2 workbench.main.js:238 [Extension Host] Python Extension: Interpreters returned by PipEnvService are of count 1 workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: true workbench.main.js:238 [Extension Host] Python Extension: Hide locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: All locators have completed locating, Class name = p, , Return Value: undefined 2 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, workbench.main.js:238 [Extension Host] Python Extension: Selected Interpreter from workspaceEnvs, {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"PipEnv","pipEnvWorkspaceFolder":"/home/ndp/sandbox/sandbox"} workbench.main.js:238 [Extension Host] Python Extension: Rule = workspaceEnvs, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from workspaceEnvs workbench.main.js:238 [Extension Host] Python Extension: Current value for rule system is {"architecture":3,"path":"/usr/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/usr","fileHash":"4399b1f9f46fd0eb65553c9cdc3826517b80fa4937cd32d858a5c09438b79f3a04f4998e30768e875c25e97c47c364920e12093a55590edfe900d750f469af23","type":"Unknown","displayName":"Python 3.7.3 64-bit"} workbench.main.js:238 [Extension Host] Python Extension: Current value for rule currentPath is {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"} workbench.main.js:238 [Extension Host] Python Extension: Current value for rule windowsRegistry is nothing workbench.main.js:238 [Extension Host] Python Extension: Selected Interpreter from cachedInterpreters, {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"} workbench.main.js:238 [Extension Host] Python Extension: setGlobalInterpreter, Class name = f, Arg 1: {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"}, Arg 2: , Return Value: true workbench.main.js:238 [Extension Host] Python Extension: Rule = cachedInterpreters, result = exit 3 workbench.main.js:238 [Extension Host] Python Extension: autoSelectInterpreter, Class name = f, Arg 1: , Arg 2: , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking support of .NET, Class name = c, , Return Value: true workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Python Extension: Rule = windowsRegistry, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from windowsRegistry workbench.main.js:238 [Extension Host] Python Extension: Rule = settings, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from settings workbench.main.js:238 [Extension Host] Python Extension: Build the workspace interpreter watcher, Class name = h, Arg 1: , Return Value: 2 workbench.main.js:238 [Extension Host] Python Extension: autoSelectInterpreter, Class name = f, Arg 1: , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Selected Interpreter from currentPath, {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"} workbench.main.js:238 [Extension Host] Python Extension: Current value for rule system is {"architecture":3,"path":"/usr/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/usr","fileHash":"4399b1f9f46fd0eb65553c9cdc3826517b80fa4937cd32d858a5c09438b79f3a04f4998e30768e875c25e97c47c364920e12093a55590edfe900d750f469af23","type":"Unknown","displayName":"Python 3.7.3 64-bit"} workbench.main.js:238 [Extension Host] Python Extension: Current value for rule currentPath is {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"} workbench.main.js:238 [Extension Host] Python Extension: Current value for rule windowsRegistry is nothing workbench.main.js:238 [Extension Host] Python Extension: Selected Interpreter from cachedInterpreters, {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"} workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Display locator refreshing progress, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Notify locators are locating, Class name = p, , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Detected refreshing of Interpreters, Class name = p, Arg 1: {}, Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Get language server folder name, Class name = f, Arg 1: , Return Value: "languageServer.0.2.82" workbench.main.js:238 [Extension Host] Python Extension: Selected Interpreter from system, {"architecture":3,"path":"/usr/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/usr","fileHash":"4399b1f9f46fd0eb65553c9cdc3826517b80fa4937cd32d858a5c09438b79f3a04f4998e30768e875c25e97c47c364920e12093a55590edfe900d750f469af23","type":"Unknown","displayName":"Python 3.7.3 64-bit"} workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Python Extension: Get language server folder name, Class name = f, Arg 1: , Return Value: "languageServer.0.2.82" workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox/src/sandbox/__init__.py 3 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox/src/sandbox/__init__.py 3 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox workbench.main.js:238 [Extension Host] Python Extension: setGlobalInterpreter, Class name = f, Arg 1: {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"}, Arg 2: undefined, Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Rule = currentPath, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from currentPath workbench.main.js:238 [Extension Host] Python Extension: autoSelectInterpreter, Class name = f, Arg 1: , Return Value: undefined workbench.main.js:238 [Extension Host] Python Extension: Activation Commands received source /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/activate 2 workbench.main.js:238 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /home/ndp/sandbox/sandbox/src/sandbox/__init__.py workbench.main.js:238 [Extension Host] Python Extension: Has Custom Env Vars workbench.main.js:238 [Extension Host] Python Extension: Activating Environment to capture Environment variables, . /home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/ndp/.vscode/extensions/ms-python.python-2019.4.12954/pythonFiles/printEnvVariables.py workbench.main.js:238 [Extension Host] Python Extension: parseEnvironmentOutput, Class name = S workbench.main.js:238 [Extension Host] Python Extension: getActivatedEnvironmentVariables, Class name = S, Arg 1: workbench.main.js:238 [Extension Host] Python Extension: Get language server folder name, Class name = f, Arg 1: , Return Value: "languageServer.0.2.82" workbench.main.js:238 [Extension Host] Python Extension: setGlobalInterpreter, Class name = f, Arg 1: {"architecture":3,"path":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/home/ndp/.virtualenvs/sandbox-XSv3_Pyv","fileHash":"cdd6e951c90483aa07c107b1a00e2c82167810ca7523f2449138a070e934da62e55e746da4947eacaff5692a71c39cff43e27c41ee41bbe79b4459ca4720db21","type":"Unknown"}, Arg 2: undefined, Return Value: false workbench.main.js:238 [Extension Host] Python Extension: setGlobalInterpreter, Class name = f, Arg 1: {"architecture":3,"path":"/usr/bin/python","version":{"raw":"3.7.3-final","major":3,"minor":7,"patch":3,"prerelease":["final"],"build":[],"version":"3.7.3-final"},"sysPrefix":"/usr","fileHash":"4399b1f9f46fd0eb65553c9cdc3826517b80fa4937cd32d858a5c09438b79f3a04f4998e30768e875c25e97c47c364920e12093a55590edfe900d750f469af23","type":"Unknown","displayName":"Python 3.7.3 64-bit"}, Arg 2: undefined, Return Value: false workbench.main.js:238 [Extension Host] Python Extension: Rule = cachedInterpreters, result = runNextRule workbench.main.js:238 [Extension Host] Python Extension: Executing next rule from cachedInterpreters  ```

@karrtikr commented on Wed May 22 2019

Please create a .env file in the root directory with content PYTHONPATH=./src, and see if that resolves the warnings.


@potens1 commented on Wed May 22 2019

Hi, I created it, tried with .src, ./src, or src, and no, it does not change anything. By the way, in my setup.py, the package_dir already specify where to find the package (if this should/could be understood by the extension)

image

Thank you


@karrtikr commented on Wed May 22 2019

Setting PYTHONPATH=./src and reloading is expected to find sandbox. Moving this issue, please follow up in the mentioned link.

ananyabijaya commented 5 years ago

Hi, I am experiencing a similar problem. Even after setting up the .env file with PYTHONPATH, I am not able import modules in the subdirectories of the project. For now, I have to explicitly append the path of the root folder in the python file. Is there a way to globally set the PYTHONPATH to the project folder, when using "run python file in terminal".

jakebailey commented 5 years ago

At the moment, our current recommendation is to use the extraPaths configuration to point the LS to your import roots. See the new documentation here: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings

A fix to editable installs was merged in #1183 (v0.3.1+), and will be available in the daily download channel shortly (and stable likely after). To switch to this for testing, you can set:

"python.analysis.downloadChannel": "daily"

Inferring this information automatically is more difficult than it seems, but there is likely work that can be done on that front in the future.