11/24/2021»»Wednesday

Install Python With Homebrew

Installation happens with the brew command, which gives us access to thousands of command-line utilities, but not more complex applications. For us nerds, the utilities that fit into 'the stuff you need' category include the handy tree command that shows directory structures and pyenv, which I use to manage multiple versions of Python. On Windows, you should open Command Prompt ( ⊞Win-r and type cmd) and run the same command. C: pip install -U sphinx. After installation, type sphinx-build -version on the command prompt. If everything worked fine, you will see the version number for the Sphinx package you just installed.

Instructions for a supported install of Homebrew are on the homepage.

This script installs Homebrew to its preferred prefix (/usr/localfor macOS Intel, /opt/homebrew for Apple Silicon and /home/linuxbrew/.linuxbrew for Linux) so thatyou don’t need sudo when youbrew install. It is a careful script; it can be run even if you have stuffinstalled in the preferred prefix already. It tells you exactly what it will do beforeit does it too. You have to confirm everything it will do before it starts.

macOS Requirements

  • A 64-bit Intel CPU or Apple Silicon CPU 1
  • macOS Mojave (10.14) (or higher) 2
  • Command Line Tools (CLT) for Xcode: xcode-select --install,developer.apple.com/downloads orXcode3
  • The Bourne-again shell for installation (i.e. bash) 4

Git Remote Mirroring

You can set HOMEBREW_BREW_GIT_REMOTE and/or HOMEBREW_CORE_GIT_REMOTE in your shell environment to use geolocalized Git mirrors to speed up Homebrew’s installation with this script and, after installation, brew update.

The default Git remote will be used if the corresponding environment variable is unset.

Alternative Installs

Linux or Windows 10 Subsystem for Linux

Check out the Homebrew on Linux installation documentation.

Untar anywhere

Just extract (or git clone) Homebrew wherever you want. Just avoid:

  • Directories with names that contain spaces. Homebrew itself can handle spaces, but many build scripts cannot.
  • /tmp subdirectories because Homebrew gets upset.
  • /sw and /opt/local because build scripts get confused when Homebrew is there instead of Fink or MacPorts, respectively.
Install python 3.7 with homebrew

However do yourself a favour and use the installer to install to the default prefix. Some things maynot build when installed elsewhere. One of the reasons Homebrew justworks relative to the competition is because we recommend installinghere. Pick another prefix at your peril!

or

then

Multiple installations

Create a Homebrew installation wherever you extract the tarball. Whichever brew command is called is where the packages will be installed. You can use this as you see fit, e.g. a system set of libs in the default prefix and tweaked formulae for development in ~/homebrew.

Uninstallation

Uninstallation is documented in the FAQ.

1 For 32-bit or PPC support seeTigerbrew.

Install Python 3.5 Homebrew

2 10.14 or higher is recommended. 10.9–10.13 aresupported on a best-effort basis. For 10.4-10.6 seeTigerbrew.

3 Most formulae require a compiler. A handfulrequire a full Xcode installation. You can install Xcode, the CLT, or both;Homebrew supports all three configurations. Downloading Xcode may require anApple Developer account on older versions of Mac OS X. Sign up for freehere.

4 The one-liner installation method found onbrew.sh requires the Bourne-again shell, i.e. bash.Notably, zsh, fish, tcsh and csh will not work.

Installation from PyPI¶

Sphinx packages are published on the Python Package Index. The preferred tool for installingpackages from PyPI is pip. This tool is provided with all modernversions of Python.

On Linux or MacOS, you should open your terminal and run the following command.

Install

On Windows, you should open Command Prompt (⊞Win-r and typecmd) and run the same command.

After installation, type sphinx-build --version on the commandprompt. If everything worked fine, you will see the version number for theSphinx package you just installed.

With

Installation from PyPI also allows you to install the latest developmentrelease. You will not generally need (or want) to do this, but it can beuseful if you see a possible bug in the latest stable release. To do this, usethe --pre flag.

Using virtual environments¶

When installing Sphinx using pip,it is highly recommended to use virtual environments,which isolate the installed packages from the system packages,thus removing the need to use administrator privileges.To create a virtual environment in the .venv directory,use the following command.

Install Python 2.7 With Homebrew

You can read more about them in the Python Packaging User Guide.

Homebrew

Install Python With Homebrew Software

Warning

Note that in some Linux distributions, such as Debian and Ubuntu,this might require an extra installation step as follows.

Most Viewed Posts