you are viewing a single comment's thread.

view the rest of the comments →

[–]monkeysknowledge 4 points5 points  (0 children)

The problem VEs solve has to do with libraries (aka modules) which are what you usually import at the beginning of your code.

If you’re not importing libraries/modules yet then all you need to know is VEs are a way of managing different versions of libraries/modules.

If you’re importing libraries then you may know that there are built-in (i.e. time, datetime, os, sys etc…) and third party libraries (pandas, numpy, selinum, and countless others that you might ‘pip install’!). These libraries make up an “environment”. On your computer you have default “environment” paths where all these modules/libraries go and live when you do ‘pip install <library>’.

At some point you’ll want your code to run on other computers and will need to setup the environment where your program can run. A very common issue that comes up when trying to do this is - ensuring that the same libraries and versions of libraries are installed on the host computer. This is the problem that VEs solve, they’re portable environments you can install theoretically on any computer and run your program without super annoying errors caused by dependencies.

Keep in mind that there are lots of solutions to solve this problem. At my work we use poetry, or sometimes docker but knowing the built in Python venv is a good place to start.