microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

vscode trying but failing to use my uv venv #24208

Open MaxPowerWasTaken opened 2 weeks ago

MaxPowerWasTaken commented 2 weeks ago

Type: Bug

I have the following code in my main.py:

import pymupdf

print(f"pymupdf version is: {pymupdf.__version__}")

I can create a python3.12 environment with pymupdf installed and run it from my (kubuntu24.04) shell without issues, with the following commands (showing shell log after each >command):

>uv --version
uv 0.4.17

>uv init --no-pin-python
Initialized project `askliz2`

>uv venv --python 3.12.6 
Using CPython 3.12.6
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate

>source .venv/bin/activate 
askliz2>uv add pymupdf 
Resolved 3 packages in 281ms
Installed 2 packages in 11ms
 + pymupdf==1.24.10
 + pymupdfb==1.24.10

askliz2>python main.py
pymupdf version is: 1.24.10

However, when I launch vscode from this folder with my uv venv activated with code ., and then highlight the line import pymupdf and hit shift+enter to run it in the integrated terminal, I get the following vscode integrated terminal output:

/home/max/askliz2/.venv/bin/python 
Python 3.12.6 (main, Sep  9 2024, 22:11:19) [Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
]633;E;exit()]633;D;0]633;A>>> ]633;B]633;Cimport pymupdf
]633;E;import pymupdf]633;D;0]633;A>>> ]633;B]633;C

Things I've tried so far:

When I use the command pallet to select python interpreter, it shows me it's trying to use Python 3.12.6('.venv') ./.venv/bin/python, as it should be, and as the vscode integrated logs above already indicate.

VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS version: Linux x64 6.10.6-061006-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz (8 x 2800)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off| |Load (avg)|3, 3, 2| |Memory (System)|15.41GB (9.05GB free)| |Process Argv|. --crash-reporter-id 278e8daa-3421-43f0-a591-500f30110725| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
Extensions (26) Extension|Author (truncated)|Version ---|---|--- aws-toolkit-vscode|ama|3.26.0 markdown-checkbox|bie|0.4.0 markdown-mermaid|bie|1.25.0 minizinc|Dek|0.1.1 copilot|Git|1.234.1129 copilot-chat|Git|0.21.2024090602 language-julia|jul|1.124.2 json-lines-viewer|leh|0.0.4 vscode-docker|ms-|1.29.3 debugpy|ms-|2024.10.0 isort|ms-|2023.10.1 python|ms-|2024.14.1 vscode-pylance|ms-|2024.9.2 jupyter|ms-|2024.8.1 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.19 vscode-jupyter-cell-tags|ms-|0.1.9 vscode-jupyter-slideshow|ms-|0.1.6 remote-containers|ms-|0.384.0 remote-ssh|ms-|0.114.3 remote-ssh-edit|ms-|0.86.0 remote-explorer|ms-|0.4.3 vsliveshare|ms-|1.0.5941 vsliveshare-pack|ms-|0.4.0 diagramspreviewer|teh|1.0.9 json|Zai|2.0.2
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 01bff139:31013167 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 impr_priority:31102340 nativerepl1:31139838 refactort:31108082 pythonrstrctxt:31112756 flighttreat:31134774 wkspc-onlycs-t:31132770 nativeloc1:31134641 wkspc-ranged-c:31125598 cf971741:31144450 autoexpandse:31146404 iacca2:31144504 cc771715:31146322 ```
karthiknadig commented 2 weeks ago

@Tyriar This looks like a terminal bug.

MaxPowerWasTaken commented 2 weeks ago

hey, sorry to be persistent, but any idea how I might fix or get around this? I'd really love to use vscode with uv...