2

I'm following a tutorial from a Windows guy creating a bash script to start Virtualenvironment in VScode.

I try to do the same thing under Linux Ubuntu 20.10. I use last version of VSCode (1.53.2)

I hope it's not needed to buy windows PC to automatize with bash scripts !!

Here is my script and the file is open_project.sh :

 #!/bin/bash
    cd /home/fablab/Desktop/dev/mycoffee/venv
    source bin/activate && code .

I expect this result :

VScode venv ok

But I get this behavior :

VScode venv nok

I tried suggestions from thread https://stackoverflow.com/questions/13122137/how-to-source-virtualenv-activate-in-a-bash-script:

Suggestion1

Any idea ? Maybe works in windows because the terminal (cmd ?) is linked with vscode terminal somehow ?

Edit :

It works is I launch the bash from VSCode terminal using :

source open_project.sh

But I would like it to work from desktop by double clicking the open_project.sh ...

Edit :

I tried a different way but still not satisfying :

added in the settings.json :

"python.terminal.activateEnvironment": true

but still no activated venv on start (the loading of the seetings happens after the launch therefore I still need to manually relaunch the terminal to get venv activated ...

Still stuck, nobody ?

8
  • What is the output of echo $VIRTUAL_ENV
    – Raja G
    Feb 17, 2021 at 18:34
  • returns nothing, in ubuntu terminal or in vscode terminal
    – Chwal
    Feb 17, 2021 at 18:41
  • Thanks, I managed to activate venv inside the terminal through the bash script using this question, but never managed to do it inside VScode ... what do I do wrong ?
    – Chwal
    Feb 17, 2021 at 19:33
  • When you say code ., you are opening, it will open visual studio code with current directory as project folder, but you never instructed visual studio code about virtual environment.
    – Raja G
    Feb 18, 2021 at 4:53

0

You must log in to answer this question.

Browse other questions tagged .