Home > Software engineering >  Do I need a clean install of Python to start working with virtual environments?
Do I need a clean install of Python to start working with virtual environments?

Time:05-02

I've been using Python on my system for about a year as a new programmer. Until recently, the topic of virtual environments hasn't come up until got to the end point of the Django course on codecademy. I'm now expected to make a Django project on my own system.

I have been just installing packages to Python without making virtual environments in the past as I wasn't aware that it was recommended to create an environment for each project.

Should I have a clean install of Python before I start using virtual environments?

If so, is there a pip command to uninstall all non-python native packages and essentially reset the install?

CodePudding user response:

Should I have a clean install of Python before I start using virtual environments?

No, it's not needed. Indeed, doing so would defeat the main purpose of using a virtual environment: they are used in order to "isolate" the packages of a project, without having to load the ones you have "globally" installed.

You can just create a new virtual environment and use it, everytime you make a brand new project!

CodePudding user response:

You don't necessarily need a clean install for Python to have a 'clean' environment using virtualenv.

It used to be that you would specify the --no-site-packages flag to remove visibility of the globally installed packages like the below:

virtualenv --no-site-packages venv_name

However, this is now the default option for virtualenv, and you don't need to do it explicitly unless you are running a very old version.

  • Related