File: linux.md

package info (click to toggle)
bornagain 23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,948 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (64 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download | duplicates (2)
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
+++
title = "Python on Linux"
weight = 10
+++

## Install Python on Linux

Any Linux distribution (Debian/Ubuntu, Fedora, etc) provides packages
for Python and for many Python modules. This approach, however, runs into
difficulties if one needs Python modules that are _not_ available in the
distribution. Installing them using the Python package manager Pip can
cause inconsistencies and break the system. Therefore, distributions at
some point (e.g. Debian 12) disabled Pip, which terminates with
`error: externally-managed-environment`. While this behavior can be
overridden by a special flag, we advise against.
Rather, we recommend escaping from Python version hell by using the
Python version manager [pyenv](https://github.com/pyenv/pyenv).

#### Requirements

To provide a backend for the Python plotting module matplotlib,
install the GUI toolkit Tk before installing pyenv (otherwise,
you will need to rerun `pyenv install <version>`).
Also, two other development packages are required.
A warning about missing sqlite3 support can be ignored.

| Distribution | Packages  |
| ------------ | --------  |
| Debian       | tk-dev   libssl-dev   libreadline-dev |
| Redhat       | tk-devel libssl-devel libreadline-devel |
| Archlinux    | Tk       ? ? |


#### Python in pyenv

Pyenv installation requires a few more libraries and headers:

| Distribution | Packages  |
| ------------ | --------  |
| Debian       | libffi-dev libsqlite3-dev libbz2-dev liblzma-dev |

Prepare the shell by adding
```
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
```
to `~/.bashrc` (or whatever startup configuration file), and
restart the shell.

Then:
```bash
# install pyenv
curl https://pyenv.run | bash

# install Python (e.g. {{% recommended-python %}})
pyenv install {{% recommended-python %}}
pyenv global {{% recommended-python %}}
which python # shows path in virtual environment

# install Python modules
pip install numpy matplotlib corner emcee lmfit scipy tqdm wheel auditwheel setuptools
```
For explanations, see the page on required or recommended [modules](modules).