Detailed installation guide for macOS¶
This is a step-by-step guide intended for those unfamiliar with Python or the command-line (a.k.a. the “shell”).
A shell can be opened by opening a new tab in the Terminal app (located in
Utilities). Text that is
formatted like code is meant to be copied and
pasted into the terminal (hit the Enter key to run the command).
The fist step is to install the versions of Python that we need. The most convenient way of doing this is to use the Miniconda distribution of Python. Install Miniconda by downloading and running the installer script:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o Miniconda3-latest-MacOSX-x86_64.sh
Then run it with:
Once you have installed Miniconda, close and re-open your Terminal window
and confirm that your
python command points to the Minconda-installed
version of Python, rather than your computers’s default Python, by running
which python. This should print something like
Using the Miniconda Python rather than the version of Python that comes with your computer will protect your computer’s Python version from unwanted changes that could interfere with other applications.
Now we want to use the
conda command-line tool (installed with Miniconda)
to create an isolated Python environment
within which to install PyPhi. Environments allow different projects to
isolate their dependencies from one another, so that they don’t interact in
conda create --name <name_of_your_project>
Once we’ve created the environment, we need to “activate” it so that when we
run Python or install Python packages, we’re doing those things inside the
isolated environment. To activate the environment we just created, run
conda activate <name_of_your_project> (and to deactivate it, run
deactivate, or start a new Terminal session).
Remember to activate your project’s environment every time you begin
working on your project. Also, note that the currently active virtual
environment is not associated with any particular folder; it is
associated with a Terminal session. In other words, each time you open a
new Terminal tab or Terminal window, you need to run
<name_of_your_project. When the environment is active, your
command-line prompt should show the name of the environment.
The first thing we need to do inside the new environment is install Python:
… code:: bash
conda install python
Now we’re ready to install PyPhi. To do this, we’ll use
pip, the Python
pip install pyphi
Congratulations, we’ve just installed PyPhi!
pip install ipython
Now we can run
ipython to start an IPython session. In the Python
command-line that appears (it’s preceded by the
>>> prompt), run
Now you’ve imported PyPhi and can start using it!