m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/python.md
blob: 0dca522646c3183e7f22b2d420a84a442eaace8e (plain)
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
# Python

## Virtual Envs

Create:

    python3 -m venv <env name>

Run:

    source <env name>/bin/activate

### requirements.txt

Create based on currently installed packages:

    pip freeze > requirements.txt

Install from requirements:

    python -m pip install -r requirements.txt

## Executing a package

Create `./package/__main__.py` script you want to execute. Then

    python -m package

## Jupyter Notebook

Setting default browser:

    # generates a config file under ~/.jupyter/
    jupyter notebook --generate-config
    # edit the newly generated config
    c.NotebookApp.browser = '<browser command> %s'

Using a venv:

    # once in venv
    pip install ipykernel
    python -m ipykernel install --user --name <name for the env in Jupyter>
    # then select the new kernel in the web app