[Python] How to source virtualenv activate in a Bash script

Discussão em 'Python' iniciado por Stack, Maio 9, 2025.

  1. Stack

    Stack Membro Participativo

    How do you create a Bash script to activate a Python virtualenv?

    I have a directory structure like:

    .env
    bin
    activate
    ...other virtualenv files...
    src
    shell.sh
    ...my code...


    I can activate my virtualenv by:

    user@localhost:src$ . ../.env/bin/activate
    (.env)user@localhost:src$


    However, doing the same from a Bash script does nothing:

    user@localhost:src$ cat shell.sh
    #!/bin/bash
    . ../.env/bin/activate
    user@localhost:src$ ./shell.sh


    What am I doing wrong?

    Continue reading...

Compartilhe esta Página