1. Install Python Via Homebrew Kit
  2. Install Python Via Homebrew Command
  3. Install Python Via Homebrew Ssh

This tutorial walks you through installing and using Python packages.

It will show you how to install and use the necessary tools and make strongrecommendations on best practices. Keep in mind that Python is used for a greatmany different purposes, and precisely how you want to manage your dependenciesmay change based on how you decide to publish your software. The guidancepresented here is most directly applicable to the development and deployment ofnetwork services (including web applications), but is also very well suited tomanaging development and testing environments for any kind of project.


Install Python Via Homebrew

  • Homebrew-specific issues. If you get legacy warnings even though you installed the latest homebrew version of heroku, this is happening because the binary heroku command in your PATH environment variable is not pointing to the version that brew installed. First, run which heroku to see what binary heroku is pointing to.
  • Installing or updating Python on your computer is the first step to becoming a Python programmer. There are a multitude of installation methods: you can download official Python distributions from Python.org, install from a package manager, and even install specialized distributions for scientific computing, Internet of Things, and embedded systems.
  • If you installed Python from source, with an installer from python.org, or via Homebrew you should already have pip. If you’re on Linux and installed using your OS package manager, you may have to install pip separately.
  • Via homebrew and pip with Python3. On MacOSX (10.13.510.15.x): $ brew install python $ brew install graphicsmagick $ brew install boost-python3 $ pip install pgmagick.

Pre-built Armadillo packages can also be installed via MacPorts or Homebrew the pre-built packages may not be the latest version; if you”re encountering problems, use the official stable version provided here Windows.

This guide is written for Python 3, however, these instructionsshould work fine on Python 2.7—if you are still using it, for some reason.

Make sure you’ve got Python & pip¶

Before you go any further, make sure you have Python and that it’s availablefrom your command line. You can check this by simply running:

You should get some output like 3.6.2. If you do not have Python, pleaseinstall the latest 3.x version from python.org or refer to theInstalling Python section of this guide.

Install Python Via Homebrew


If you’re newcomer and you get an error like this:

It’s because this command is intended to be run in a shell (also calleda terminal or console). See the Python for Beginnersgetting started tutorial for an introduction to using your operatingsystem’s shell and interacting with Python.

Additionally, you’ll need to make sure you have pip available. You cancheck this by running:

If you installed Python from source, with an installer from python.org, orvia Homebrew you should already have pip. If you’re on Linux and installedusing your OS package manager, you may have to install pip separately.


Installing Pipenv¶

Pipenv is a dependency manager for Python projects. If you’re familiarwith Node.js’ npm or Ruby’s bundler, it is similar in spirit to thosetools. While pip can install Python packages, Pipenv is recommended asit’s a higher-level tool that simplifies dependency management for common usecases.

Use pip to install Pipenv:


This does a user installation to prevent breaking any system-widepackages. If pipenv isn’t available in your shell after installation,you’ll need to add the user base’s binary directory to your PATH.

On Linux and macOS you can find the user base binary directory by runningpython-msite--user-base and adding bin to the end. For example,this will typically print ~/.local (with ~ expanded to theabsolute path to your home directory) so you’ll need to add~/.local/bin to your PATH. You can set your PATH permanently bymodifying ~/.profile.

On Windows you can find the user base binary directory by runningpy-msite--user-site and replacing site-packages withScripts. For example, this could returnC:UsersUsernameAppDataRoamingPython36site-packages so you wouldneed to set your PATH to includeC:UsersUsernameAppDataRoamingPython36Scripts. You can set youruser PATH permanently in the Control Panel. You may need to logout for the PATH changes to take effect.

Installing packages for your project¶

Pipenv manages dependencies on a per-project basis. To install packages,change into your project’s directory (or just an empty directory for thistutorial) and run:

Install Python Via Homebrew Kit

Pipenv will install the excellent Requests library and create a Pipfilefor you in your project’s directory. The Pipfile is used to track whichdependencies your project needs in case you need to re-install them, such aswhen you share your project with others. You should get output similar to this(although the exact paths shown will vary):

Using installed packages¶

Now that Requests is installed you can create a simple main.py file touse it:

Then you can run this script using pipenvrun:

Install Python Via Homebrew Command

You should get output similar to this:

Using $pipenvrun ensures that your installed packages are available toyour script. It’s also possible to spawn a new shell that ensures all commandshave access to your installed packages with $pipenvshell.

Next steps¶

Install Python Via Homebrew Ssh

Congratulations, you now know how to install and use Python packages! ✨ 🍰 ✨