[Python] VS Code: Source activate running after Python Run command [After updating]

Discussão em 'Python' iniciado por Stack, Julho 19, 2025.

  1. Stack

    Stack Membro Participativo

    I don't know its a bug or what, but it wasn't before updating vs code. The problem is simple. I have created & selected a venv in the working folder in vs code. When I try to run a python file (with code runner in terminal) vs code does:

    1. Runs python file: python -u file.py which uses global environment
    2. Then, it runs venv activation command: source path/to/activate.fish

    when I run it again (i.e press the shortcut), vs code runs the python command only and there is no problem afterwards, since the venv is already activated.

    So, it's not a major problem, but still kinda annoying. And this problem came after updating vs code.

    It maybe noted that I am using fish shell by default. But I switched to bash, but the results are the same. Here is a complete log:

    python -u "/home/zarir/Documents/Projects/ReDHaT_SmartAI/panel/__init__.py"
    Welcome to fish, the friendly interactive shell
    Type help for instructions on how to use fish
    zarir@radxa-x4 ~/D/P/ReDHaT_SmartAI (main)> python -u "/home/zarir/Documents/Projects/ReDHaT_SmartAI/panel/__init__.py"
    Traceback (most recent call last):
    File "/home/zarir/Documents/Projects/ReDHaT_SmartAI/panel/__init__.py", line 1, in <module>
    from flask import Flask
    ModuleNotFoundError: No module named 'flask'
    zarir@radxa-x4 ~/D/P/ReDHaT_SmartAI (main) [1]> source /home/zarir/Documents/Projects/ReDHaT_SmartAI/.venv/bin/activate.fish
    (.venv) zarir@radxa-x4 ~/D/P/ReDHaT_SmartAI (main)> echo Pressing Run Shortcut
    Pressing Run Shortcut
    (.venv) zarir@radxa-x4 ~/D/P/ReDHaT_SmartAI (main)> python -u "/home/zarir/Documents/Projects/ReDHaT_SmartAI/panel/__init__.py"
    File Executed
    (.venv) zarir@radxa-x4 ~/D/P/ReDHaT_SmartAI (main)>

    Continue reading...

Compartilhe esta Página