skip to Main Content

I created a virtual enviornment (venv) called .MF39 on my local machine in windows and pushed this into a git repository, lets call the repository: "mastermind".

When I now go on a different machine and run the commands in the terminal of visual studio code:

git pull

and afterwards the virtual enviornment is also pulled and popped up in the explorer:
enter image description here

How can I use that one now on a different machine/ activate the enviornment?

2

Answers


  1. You can use your virtual environment in VS Code by using venvScriptsactivate in your VS Code terminal.
    As a shortcut you can also set the interpreter for your VS Code project by

    1. [CTRL] + [Shift] + [P] to open the command palette
    2. Choose "Python: Select interpreter"

    Usually your venv is already recommended by VS Code and if you select it here it will automatically be activated whenever you open that project in VS Code.

    One thing in general:
    You shouldn’t put your virtual environment in Git. Usually you would set it up one, install your packages and do a python -m pip freeze > requirements.txt to save your installed packages. That is all you need to recreate the virtual environment on another system and only the requirements should be in Git.

    Login or Signup to reply.
  2. In the command line you can type source .MF39/bin/activate.

    In vscode, you first need to have the python extension installed, once that’s done it will detect your virtual environment. It may prompt you to select it, or may just automatically apply that environment.

    You can select a specific python virtual environment by hitting ctrl+shift+p and typing select interpreter, which will let you select between all known interpreters.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search