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.
Python Releases for Mac OS X. Latest Python 3 Release - Python 3.4.0; Latest Python 2 Release - Stable Releases. Python 2.7.8 - July 2, 2014. Download Mac OS X 32-bit i386/PPC installer; Download Mac OS X 64-bit/32-bit installer; Python 2.7.7 - June 1, 2014. Python comes pre-installed on Mac OS X so it is easy to start using. However, to take advantage of the latest versions of Python, you will need to download and install newer versions alongside the system ones. The easiest way to do that is to install one of the binary installers for OS X from the Python Download page. Python 2 is bundled with Mac OS X. However, Python 3 is not. We recommend that you download and install Python 3, and use Python 3 exclusively when running programs associated with this booksite. Perform these steps to download and install Python, IDLE, Tkinter, NumPy, and PyGame.
Install Virtualenv with pipx
Install Virtualenv with pip
I just want to watch the video!
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 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.
There are multiple ways to install Virtualenv so I will show a couple different ones.
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.
Virtualenv DocumentationAlternatively 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 DocumentationMake sure when using this command you are specifying python3 and not just python
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.
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!
You can find the video for this and other Web Development tutorials at our Youtube Channel DeadbearCode!
There is a known issue with version 3.7 of Anaconda Python and certain versions of the Mac OSX operating system. We strongly recommend that you use python 3.6 on OSX to avoid any problems. To install python 3.6, please follow the steps below:
To get started you need to download the OSX miniconda installer.
Click on the link https: https://repo.continuum.io/miniconda/Miniconda3-4.5.4-MacOSX-x86_64.sh to download the Python 3.6 installer.
Wait for it to download. It will place a file called Miniconda3-4.5.4-MacOSX-x86_64.sh in your downloads folder. On my computer using Safari this is ~/Downloads
Open a Terminal window. If you don’t know how to do this click * Applications -> Utilities -> Terminal*
Within the Terminal change directories into the folder where your downloaded file lives, i.e.
Now run the bash “shell” program to install Miniconda
Scroll through the license (press the space bar to move through quickly), type ‘yes’ to approve the terms, and then accept all the installation defaults.
Close the Terminal program. Then, restart it.
Within the Terminal type:
Enter y at the Proceed prompt.
When the installation completes, close the Terminal window.
The second half of the installation is the Spyder IDE development environment. This is the software that you use to write, edit and test your Python programs. Spyder IDE calls Python to actually run the program. Spyder is included by default in the Anaconda Python distribution, which comes with everything you need to get started in an all-in-one package.
However, with Miniconda, we have to download and install Spyder IDE.
Go to the Terminal window.
Type the following command:
This will take some time to download.
When the following prompt appears:
Type y, and hit enter.
Once the download is finished, type the following command to know the location of Spyder:
It is usually installed in the bin folder within miniconda3
To start Spyder, go to a terminal window and enter
You are running 64-bit Mac OS X.
Technically, all Apple computers purchased since Q4 2006 have been equipped with 64-bit capable processors. The Mac OS X operating system has supported 64-bit by default since OS X 10.6 Snow Leopard, released in 2009. The upgrade to the latest operating system for your computer is available for free, directly from Apple, since the release of OS X 10.9 Mavericks in 2013.