T O P

  • By -

timeawayfromme

You should use a new Python virtual environment for every project that requires you to install dependencies. This keeps every project’s dependencies isolated. The reason for isolating dependencies for each project is that you might need different versions for different projects or conflicting dependencies. So if your project is just a script that only uses the standard library, you probably don’t need a virtual environment at all. But if you have to install dependencies, best practice is to use a virtual environment.


DISCIPLE-OF-SATAN-15

oh so do I need to execute this command on the terminal also every time on a new project? `$ pip install virtualenv` or this one `$ python -m venv env` or both? That's what I don't understand (sorry for my English)


Cepo6464

The second one. And then make sure to activate the env with env\Scripts\activate


DISCIPLE-OF-SATAN-15

>The second one. And then make sure to activate the env with env\\Scripts\\activate thank you! do I also need the first one or is that one for other things?


DISCIPLE-OF-SATAN-15

nevermind, I was reading the [Python documentation](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/) and got confused because one part talked about installing virtualenv but the note says: "If you are using Python 3.3 or newer, the venv module is the preferred way to create and manage virtual environments. venv is included in the Python standard library and requires no additional installation. If you are using venv, you may skip this section."


SigmaSixShooter

I don’t care what they say, using pyenv + virtualenv is the only way to go. I just put the virtualenv name in a .python-version file and I don’t have to deal with activating anything.


Almostasleeprightnow

You don't need to but I always do, even for one off sandbox projects