workspace structure:

.env (which is at root of workspace)
PYTHONPATH=source
We're also facing this issue. Latest versions VSCode became unusable for us.
I am working on restoring this in the core extension (been busy with a giant refactoring), but as a workaround you can mirror the paths to extraPaths.
I add my path to extraPaths and the package is still not recognized. Any ideas of how to debug this?
If you can provide you set extraPaths to, we can look, but I don't think extraPaths not working is related to this issue (PYTHONPATH not being read), so I would prefer if you made a new issue with your info.
We've just hit this problem.
We have automated set up tools that create the development workspace and we use the .env file for setting the PYTHONPATH so we can be reasonably IDE agnostic. Without this feature we can't use Pylance.
Unfortunately, this isn't as simple as I had thought. With MPLS we started one server per workspace, so the environment variables made sense within each. But now with full multi-root workspace support, we can't just apply the environment variables as we did before as there's only one process. We'll need to come up with some solution to pass the environment down per-workspace, which likely means a similar solution to our pythonPath resolution (passing the info in the configuration). Along with a bunch more work to parse out PYTHONPATH and do something with it, or plumbing the variables down to all of our exec calls.
I can confirm this issue. Have an additional directory in my workspace and made that available via PYTHONPATH in the .env file, located in the workspace root. That always worked fine, however, after activating Pylance as Python language server the VS Code editor complains about unresolvable imports (i.e. those from the PYTHONPATH variable in the .env file). Switching back to the default Python language server does solve this issue for me.
Hey guys, any news on this?
I would really like to use Pylance, but w/o PYTHONPATH support it is not usable for us :-(
We'll update this thread when something changes. We're having a discussion about the future of path setting (as the current way isn't well designed to cover all of the different tooling between Pylance, the debugger, external linters, pytest, etc), but it might be possible to do what I said in my last message and hack the client to pass the environment variable down in the config or tack it on to extraPaths.
I have the same issue, but I have noticed that PYTHONPATH is properly read from .env if I run from the debugger.
Also, I have the same issue regardless whether I use jedi or pylance.
For what it's worth, I think this setting should be less obscure. By default, these things don't work in VSCode because you need to know about PYTHONPATH and its effect, and that there is no setting for that, but you have to create a .env file... and so on.
On the other side, this just works in pyCharm, because there is a setting ("Add source roots to PYTHONPATH") that is enabled by default. Just a constructive critique.
Thanks - the extrapaths (python.autoComplete.extraPaths: ["./src", "./tests"]) suggestion worked great.
Pylance is a great enhancement - thank you!
In my case worked with:
"python.analysis.extraPaths": [
"./src",
"./another_src"
]
the extraPaths worked for me but afther Dec 9th update it stopped working.
Please also be aware that the variable may contain multiple paths. The MS Python Language Server does not handle that, the bug template redirects to this Pylance, which at least works with "python.analysis.extraPaths" but that's manual.
Yes, certainly; I don't know why MPLS didn't handle that... My WIP definitely splits on the system PATH separator.
This'll be fixed in the next version of Pylance so long as you have an insiders build of the Python extension (or their stable release next week).
This issue has been fixed in version 2021.1.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202111-13-january-2021
Most helpful comment
In my case worked with: