-3

I'm new to programming and i see lots of post saying you have to create a virtual environment for better experience while working on a python project, and i can't really wrap my head on that..... First question, why do I need a virtual environment? Secondly, what happens if i don't use one Also, how do I install it what are the necessary procedures for a beginner Lastly, how do I know I'm using a virtual environment in python, like how do I tell the difference or there is none??

Hoping to get answers

Lyrixs
  • 3
  • 2
  • 1
    read this https://docs.python.org/3/library/venv.html you actually only need to read the first section. before you get to the API – Alexander Jun 23 '22 at 04:08

1 Answers1

0

why do I need a virtual environment?

Because a virtual environment will prevent clashes if you have several applications requiring different versions of Python, or different versions of some Python packages. You might not run into such issues as a beginner, but it's a good habit to have, nevertheless.

what happens if I don't use one?

You might have an application, which is unable to run, because of conflicting requirements.

how do I install it?

Running python3 -m venv my-app will create the directory my-app, containing a virtual environment. After creating a virtual environment, you can activate it with source my-app/bin/activate on Unix, or macOS, and with my-app/Scripts/activate.bat on Windows.

how do I know I'm using a virtual environment?

If you're using a virtual environment your prompt will show its name, e.g. (my-app) $.

See also the section Virtual Environments, and Packages, from The Python Tutorial.

  • Okay, now I get it. But whenever I try running python3 -m venv my-app, it keeps saying python was not found: run without arguments to install from the Microsoft store, or disable this shortcut from settings> Managed App Execution Aliases. @Dani – Lyrixs Jun 25 '22 at 04:05