Python Hands-on

Virtualenv and venv: Python virtual environments explained

Take advantage of virtual environments in Python 2 and Python 3 to manage conflicts between Python projects

Of all the reasons Python is a hit with developers, one of the biggest is its broad and ever-expanding selection of third-party packages. Convenient toolkits for everything from ingesting and formatting data to high-speed math and machine learning are just an import or pip install away.

But what happens when those packages don’t play nice with each other? What do you do when different Python projects need competing or incompatible versions of the same add-ons? That’s where Python virtual environments come into play.

You can create and work with virtual environments in both Python 2 and Python 3, though the tools are different. Virtualenv is the tool of choice for Python 2, while venv handles the task in Python 3. 

What are Python virtual environments?

To continue reading this article register now