Room 51 Mac OS

Posted on  by

TL;DR

Quick walkthrough on how to install Virtualenv on Mac OS two different ways. This is an easy way to manage Python and it’s dependencies in your projects.

Install Virtualenv with pipx

Install Virtualenv with pip

I just want to watch the video!

Mac OS ty to notify users when system updates are available. The operating system lacks any m ethod to hide unprivil eged users, has insignifi cant password strength s unnecessaril y have set -U ID and set -GID bits set and this ng (Mac OS X 10.1.4 at the time of this cular focus on NetInfo, Mac OS X s director y system,. Over at The Loop, Dave Mark commented on Apple’s list of enhancements in El Capitan. It’s an impressive list. But it really brought something into sharp relief for me: I don’t use any of the new features in recent Mac OS X updates. I was really tired of Lucida Grande and I prefer flatter design, so the interface improvements in Yosemite and now El Capitan are worth the update.

Why Virtualenv?

When working on multiple Python projects they will not always be running on the same version of Python. So a better way to manage the version of Python you are using is by creating a Virtual Environment.

Virtual Environments are isolated from the rest of your computer and are only responsible for each individual project’s Python version and the dependencies of your project.

Virtualenv is one of several tools that solves this problem.

Mac OS Python vs. Python3

Mac OS comes with a version of Python pre installed already usually 2.7.x or something of the like.

As Python2.7 is no longer supported by the maintainers of Python so going forward you are going to want to use some sort of Python3.

You can download the latest version of Python here.

You can find out which version you have by running the following command in your terminal.

When downloading Python3 this is distinguished by calling it just that, Python3.

Install Virtualenv on Mac OS

There are multiple ways to install Virtualenv so I will show a couple different ones.

How To Install Virtualenv with pipx

If you already have a Python 3.5+ interpreter the best is to use pipx to install virtualenv into an isolated environment. This has the added benefit that later you’ll be able to upgrade virtualenv without affecting other parts of the system.

Room
Virtualenv Documentation

How To Install Virtualenv with pip

Alternatively you can install it within the global Python interpreter itself (perhaps as a user package via the –user flag). Be cautious if you are using a python install that is managed by your operating system or another package manager. pip might not coordinate with those tools, and may leave your system in an inconsistent state.

Virtualenv Documentation

Make sure when using this command you are specifying python3 and not just python

Virtualenv In Action

Room 51 Mac Os X

1. Create a new project folder

2. Setup virtual environment

3. Activate virtual environment

4. Check which version of Python you have running

It should be python3.7 or the like.

5. Deactivate the virtual environment

6. Check which version of Python you are running again. It should now say the old python2.7 version.

Room 51 Mac Os Update

Summary

Room 51 Mac Os Catalina

That’s it! That is a couple ways i have seen how to install Virtualenv on Mac OS.

I hope you found this walkthrough helpful!

Room 51 Mac Os Download

How To Install Virtualenv on MAC OS Video Walkthrough

You can find the video for this and other Web Development tutorials at our Youtube Channel DeadbearCode!