1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
:orphan:
.. _quickstart-pip:
======================================================================
Development environment quickstart guide using ``pip`` on Ubuntu Linux
======================================================================
This is a high-level overview of what is needed to set up a development
environment. This is only one possible way out of many. This guide assumes
you have a fresh install of Ubuntu Linux 20.04, which only has a ``python3``
executable. We also assume you have already installed ``git`` and cloned
the SciPy repository.
Installing the system-level dependencies
----------------------------------------
First, you will also need the compilers for C, C++ and Fortran::
sudo apt install -y gcc g++ gfortran
SciPy also requires BLAS and LAPACK libraries. You can install several variants
(ATLAS, OpenBLAS etc), but here we take the simplest option::
sudo apt install -y liblapack-dev
Installing the python-level dependencies
----------------------------------------
Start with installing ``pip``::
sudo apt install -y python3-pip
All further work should proceed in a virtual environment. Popular options include
the standard library ``venv`` module or a separate
``virtualenv`` package. There are muliple third-party tutorials on how to
set up a virtual environment, so we cover only briefly these two options
here.
.. note::
We repeat: all work should happen in a virtual environment. Never use ``sudo pip``.
Using ``virtualenv``
~~~~~~~~~~~~~~~~~~~~
Install the ``virtualenvwrapper`` package::
python3 -m pip install virtualenvwrapper --user
Edit the ``.bashrc`` file to add some environment variables which are used
internally by the ``virtualenvwrapper``::
export WORKON_HOME=$HOME/virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
. $HOME/.local/bin/virtualenvwrapper.sh
Here we store the virtualenvs in a ``virtualenvs`` folder in the home directory.
(you might need to create the folder manually).
Now open a new terminal window for the changes to the ``.bashrc`` to take effect.
Create a new virtual environment and activate it::
mkvirtualenv scipy-dev
Your command prompt now lists the name of your new environment, like so
``(scipy-dev)$``. This means that the environment is active. If it is not,
activate it manually with::
workon scipy-dev
Note ``mkvirtualenv`` and ``workon`` commands come from the ``virtualwrapper``
package.
Using the standard-library ``venv`` package
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Install the ``venv`` package::
sudo apt install -y python3-venv
Change the directory to your home folder and create a directory ``.venvs`` there.
Create the virtualenvironment::
python3 -m venv scipy-dev
To activate the environment, use ::
source $HOME/.venvs/scipy-dev/bin/activate
Your command prompt now lists the name of your new environment, like so
``(scipy-dev)$``.
(For the official docs for the ``venv`` package see
https://docs.python.org/3/tutorial/venv.html).
Building SciPy
--------------
Inside the ``scipy-dev`` environment, install the python-level dependencies::
python -m pip install numpy pytest cython pybind11
Note that when the virtual environment is active, the system-wide names ``pip3``
and ``python3`` are aliased to ``pip`` and ``python``, respectively.
Now that you have all needed dependencies, navigate to the directory where
you cloned the source code into, and build SciPy (this takes a while)::
python setup.py build
Optionally, test it::
python runtests.py
|