This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 2: Virtual Environments

Managing external Python packages

face Josiah Wang

The easiest way to install external packages is to directly install them to your Python user installation. So, whenever you run python3.10, the packages will immediately be made available in Python’s module search path.

Installing all packages in your main Python user installation

Let’s say one day you need to run an older project of yours. It relies on an older version of opencv (which in turn may rely on an older version of tensorflow). Your code does not work with the versions you currently have. Is it worth downgrading your installation just for this?

Or let’s say you need a specific version of PyTorch for one of your deep learning courseworks (because your lecturer is too lazy to upgrade his version!) Is it worth you downgrading your version of PyTorch? What if it affects your running of other codes that you are currently developing?

Or let’s say you need to run some cutting-edge code from the latest NLP research which rely on many of the latest versions of packages available. You could upgrade these packages in your Python installation, but what if it messes up some of your other packages? And you might risk breaking some of your existing codes which need older versions of the packages.

Luckily, we have virtual environments to solve this problem!