New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VS Code + Pylance does not find venv-installed modules while venv is activated #3881
Comments
I just tried it and it works as expected. Can you provide us some logs as described in the troubleshooting guide? and also provide us list of packages in the .venv/lib/python3.11/site-packages without that information, there is not much we can do. |
Thank you for the fast response. First find the list of installed packages.
And this is the log Python Language Server:
|
so. this and this show that we are not getting
hard to know why your python interpreter returns nothing for if you run |
I wondered myself about that entry in the log. I tried afterwards to fix it with In the terminal within VSCode, the last item is the correct site-packages directory:
|
did you make sure you are working with |
I understand the limitations of an untrusted workspace and verified that I have configured the folder as a trusted workspace. In addition, I added the folder again to the list of trusted workspace. I dont see any other limitations and the untrusted-badge in the bottom left isn't shown, too. I checked with another python project I worked in the past with and have the same pylance-Error and can't remember, I had it in the past. Please advise how to proceed. Your support is highly appreciated. |
hmm.. I assume you checked that this is what we actually run to get python search path. can you run to see what you get?
|
python path points to the .venv/bin/python, even ommitted, it does not work. This is the output of the command and includes the .venv-site-packages.
|
hmmm.. now I am not sure why you are not getting any search path..... we might need to give you some debug bits to run to see what output we get from pylance itself. |
I made a change to Pylance so that we log more on python search path. once you install our next pylance pre-release bit (2023.2.11 - which will be most likely released tomorrow afternoon), if you enable the log, it will have new entries about python search path. let's see what it says once you have the bits. |
Highly appreciated the extra effort. I looo forward to try the update and post an update as soon as possible. Just FYI: I removed the the configuration for Run/Debug as was therefore prompted to state how I want to run Debug the next time I clicked the button. I could chose Python and was afterwards prompted for Django which I confirmed and it worked seamlessly. At this part the right setup was configured by VSC. |
The output of the log is super interesting, and I think we're close to the issue. It seems, that the path of my working directory is the issue and
This is the output of pylance, which leads to a crash of the extension. It seems I am the first to work within my "iCloud Documents" folder.
|
let me take a look |
This issue has been fixed in prerelease version 2023.2.12, which we've just released. You can find the changelog here: CHANGELOG.md |
what if I use docker and not a local enviroment. How can I solve the issue |
please create a new issue with logs |
Hi, this still seems to be an issue. VSCode v1.88.1 | PyLance v2024.4.1 | Interpreter is set to .venv python. absolute path = as you can see it tries to expand the ~ as a home path. Same can be seen in OP's logs In this case there were multiple ~ in the pathname so it tried to expand it multiple times. if I change the name of the folder it works fine. absolute path = |
I am also able to repro this. Seems that it regressed at some point. Maybe due to the URI refactoring? It looks like the tests for this scenario were removed at some point? |
This issue has been fixed in prerelease version 2024.5.100, which we've just released. You can find the changelog here: CHANGELOG.md |
Type: Bug
I use VS Code Version: 1.74.3 on MacOS 13.2.
python -V
returnsPython 3.11.1
.I get the following error message:
Import "django.shortcuts" could not be resolved from source Pylance(reportMissingModuleScource)
.As you can see in the screenshot, the correct
venv
is activated and includesDjango
.I also tried or checked:
user/settings.json
as well as.vcode/settings.json
.Using Debug I can safely run my Django-application without any import issues. What do I need to do that Pylance does not issues these problems?
Extension version: 2023.1.40
VS Code version: Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T17:07:18.579Z)
OS version: Darwin x64 22.3.0
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: