skip to Main Content

(Disclaimer: New to coding and VS Code)

I’ve read through VS Code’s documentation on creating a virtual environment and I’ve used the VENV command to do so, but how do I know if my current Python files are working using that Virtual Environment.

In the folder I’m saving my .py files in, I see the .venv folder which was created. Is that it or is there more to it?

I’ve used VS Code’s terminal commands and followed the documentation instructions, but there is no documentation to tell me exactly what I’m supposed to see when it works, so I don’t know if I’m done.

I see the .venv folder which was created in the “Python Projects” folder I created before I began my code learning joirney. Is that it?

2

Answers


  1. Yes, that is it. Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.

    .venvScriptsactivate 
    
    Login or Signup to reply.
  2. You want to check if you are in the venv or not:

    Type which python into VS Code’s integrated terminal.
    If you are using the venv, it will show the path to the python executable inside the venv: (For me, the .venv folder is located in /Users/lion/example_folder, but for you it would be located differently)
    Example of which python in the venv

    If the path does not include the .venv folder inside your Python Projects folder, then you are not inside the venv.
    (Example: the path shown by the command is /usr/bin/python, but the .venv is at /user/Python Projects)

    You are not inside the venv and you want to activate it

    Inside VS Code’s terminal, type source .venv/bin/activate (Or, the absolute path: source ~/example_folder/.venv/bin/activate)

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