Python installation

From Master of Neuroscience Wiki
Revision as of 10:56, 14 October 2025 by Davrot (talk | contribs) (Created page with "## Goal Install your very own Python and keep everything under control. Questions to [David Rotermund](mailto:davrot@uni-bremen.de) We need to download a suitable Python version from [https://www.python.org](https://www.python.org). In the case we want to use PyTorch [check here](https://pytorch.org/get-started/locally/#windows-python) or TensorFlow [check here](https://www.tensorflow.org/install/pip#software_requirements) we need to check if the Python version is okay...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
    1. Goal

Install your very own Python and keep everything under control.

Questions to [David Rotermund](mailto:davrot@uni-bremen.de)

We need to download a suitable Python version from [1](https://www.python.org). In the case we want to use PyTorch [check here](https://pytorch.org/get-started/locally/#windows-python) or TensorFlow [check here](https://www.tensorflow.org/install/pip#software_requirements) we need to check if the Python version is okay.

    1. Windows

I downloaded this file: [2](https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe)

![figure 1](Image1.png)

Select "Add python.exe to Path" and then press "Install Now".

We need to update pip first:

```shell python.exe -m pip install --upgrade pip ```

      1. ffmpeg

You might need to create mp4 files. E.g. for saving matplotlib animations

Thus you need ffmpeg binaries. You find them here: [3](https://www.gyan.dev/ffmpeg/builds/)

I went for [4](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-6.0-full_build.7z)

There are differnt way to install the ffmpeg binaries (ffmpeg.exe, ffplay.exe, and ffprobe.exe). The easiest way is to put them here: %LOCALAPPDATA%\Programs\Python\Python311

      1. Linux

For Fedora:

Honestly, I didn't get this depencency thing working. And I couldn't find a solution. However, I am installing a huge amount of packages anyway such that the required stuff is part of it. :-)

```shell sudo dnf install dnf-plugins-core # install this to use 'dnf builddep' sudo dnf builddep python3 ``` Python installation (after the dependencies are solved):

```shell mkdir PySource cd PySource wget https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz tar -xvzf Python-3.12.7.tgz cd Python-3.12.7 ./configure --prefix=/home/[YOURUSERNAME]/P3.12 --enable-optimizations make -j 10 make install cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install --upgrade pip ```

        1. Bash (.bash_profile)

```shell alias pyhton3=/home/[YOURUSERNAME]/P3.12/bin/python3 alias pyhton=/home/[YOURUSERNAME]/P3.12/bin/python3 alias ipyhton=/home/[YOURUSERNAME]/P3.12/bin/ipython alias ipyhton3=/home/[YOURUSERNAME]/P3.12/bin/ipython alias python3=/home/[YOURUSERNAME]/P3.12/bin/python3 alias python=/home/[YOURUSERNAME]/P3.12/bin/python3 alias ipython=/home/[YOURUSERNAME]/P3.12/bin/ipython alias ipython3=/home/[YOURUSERNAME]/P3.12/bin/ipython alias pip3=/home/[YOURUSERNAME]/P3.12/bin/pip3 alias pip=/home/[YOURUSERNAME]/P3.12/bin/pip3 ```

And add **/home/[YOURUSERNAME]/P3.12/bin** to the **export PATH=** command.

    1. Numba

{: .topic-optional} This is an optional topic!

The question is: Is numba broken in the moment or not? First we install numpy and then numba. We will observe if numba tried to change the numpy version.

      1. Windows

```shell pip install numpy ```

```shell pip install numba ```

If so then you have to decide if you want to remove numba and the downgraded numpy version before continuing. I would remove it!

```shell pip uninstall numpy numba ```

      1. Linux

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip install numpy ```

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip install numba ```

If so then you have to decide if you want to remove numba and the downgraded numpy version before continuing. I would remove it!

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip uninstall numpy numba ```

|Package|| |---|---| |numba|[Numba is an open source JIT compiler that translates a subset of Python and NumPy code into fast machine code.](https://numba.pydata.org/)%7C

    1. Basic Packages you want to install
      1. Windows

```shell pip3 install numpy scipy pandas flake8 pep8-naming black matplotlib seaborn ipython jupyterlab mypy dataclasses-json dataconf ipympl pywavelets scikit-image opencv-python scikit-learn tqdm argh sympy jsmin pybind11 pybind11-stubgen pigar asciichartpy natsort ipykernel ```

      1. Linux

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install numpy scipy pandas flake8 pep8-naming black matplotlib seaborn ipython jupyterlab mypy dataclasses-json dataconf ipympl pywavelets scikit-image opencv-python scikit-learn tqdm argh sympy jsmin pybind11 pybind11-stubgen pigar asciichartpy natsort ipykernel filelock importlib-metadata regex fsspec ```


|Package|| |---|---| |numpy|[The fundamental package for scientific computing with Python](https://numpy.org/)%7C |scipy|[Fundamental algorithms for scientific computing in Python](https://scipy.org/)%7C |pandas|[pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool](https://pandas.pydata.org/)%7C |flake8|[Your Tool For Style Guide Enforcement](https://flake8.pycqa.org/en/latest/)%7C |pep8-naming|[Check your code against PEP 8 naming conventions](https://pypi.org/project/pep8-naming/)%7C |black|[The uncompromising code formatter](https://black.readthedocs.io/en/stable/index.html)%7C |matplotlib|[Visualization with Python](https://matplotlib.org/)%7C |seaborn|[seaborn: statistical data visualization](https://seaborn.pydata.org/)%7C |ipython|[IPython provides a rich architecture for interactive computing](https://ipython.org/)%7C |jupyterlab|[JupyterLab is the latest web-based interactive development environment for notebooks, code, and data.](https://jupyter.org/)%7C |mypy|[Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing.](http://mypy-lang.org/")| |dataclasses-json|[Easily serialize Data Classes to and from JSON](https://github.com/lidatong/dataclasses-json)%7C |dataconf|[Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support](https://github.com/zifeo/dataconf)%7C |ipympl|[Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl)%7C |pywavelets|[PyWavelets is open source wavelet transform software for Python.](https://pywavelets.readthedocs.io/en/latest/)%7C |scikit-learn|[Simple and efficient tools for predictive data analysis](https://scikit-learn.org/)%7C |scikit-image|[Image processing in Python](https://scikit-image.org/)%7C |opencv-python|[Open Source Computer Vision Library](https://opencv.org/)%7C |tqdm|[A Fast, Extensible Progress Bar for Python and CLI](https://github.com/tqdm/tqdm)%7C |argh|[Building a command-line interface?](https://pythonhosted.org/argh/) Found yourself uttering “argh!” while struggling with the API of argparse? Don’t want to lose its power but don’t need the complexity?| |sympy|[SymPy is a Python library for symbolic mathematics.](https://www.sympy.org/en/index.html)%7C |jsmin|[JavaScript minifier](https://github.com/tikitu/jsmin/)%7C |pybind11|[Seamless operability between C++11 and Python](https://github.com/pybind/pybind11)%7C |pybind11-stubgen|For mypy| |pigar|[A tool to generate requirements.txt for Python project, and more than that.](https://github.com/damnever/pigar)%7C |asciichartpy|[Nice-looking lightweight console ASCII line charts](https://github.com/kroitor/asciichart)%7C |natsort|[Simple yet flexible natural sorting in Python.](https://github.com/SethMMorton/natsort)%7C |ipykernel|IPython Kernel for Jupyter|

      1. PyTorch

[Check here](https://pytorch.org/get-started/locally/#start-locally) for a installation configurator.

    • Note: Even if you don't want to use TensorFlow, you want to install it too due to the tensorboard package.** Tensorboard allows to track the progress during learning.
        1. Windows
          1. CPU only

```shell pip3 install torch torchvision torchaudio torchtext ```

          1. NVidia GPU

```shell pip3 install torch torchvision torchaudio torchtext --index-url https://download.pytorch.org/whl/cu121 ```

        1. Linux
          1. CPU only

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install torch torchvision torchaudio torchtext --index-url https://download.pytorch.org/whl/cpu ```

          1. NVidia GPU

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install torch torchvision torchaudio torchtext ```

|Package|| |---|---| |torch|[PyTorch is a Python package that provides two high-level features: a. Tensor computation (like NumPy) with strong GPU acceleration b. Deep neural networks built on a tape-based autograd system](https://pytorch.org/)%7C |torchvision|[The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision.](https://github.com/pytorch/vision)%7C |torchaudio|[The aim of torchaudio is to apply PyTorch to the audio domain.](https://github.com/pytorch/audio)%7C |torchtext|[Models, data loaders and abstractions for language processing, powered by PyTorch](https://github.com/pytorch/text)%7C

      1. TensorFlow
        1. Windows
          1. CPU only

```shell pip3 install tensorflow ```

          1. NVidia GPU

```shell pip3 install tensorflow[and-cuda] ```

        1. Linux
          1. CPU only

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install tensorflow ```

          1. NVidia GPU

```shell cd /home/[YOURUSERNAME]/P3.12/bin ./pip3 install tensorflow[and-cuda] ```

|Package|| |---|---| |tensorflow|[TensorFlow is an open source software library for high performance numerical computation. Its flexible architecture allows easy deployment of computation across a variety of platforms (CPUs, GPUs, TPUs), and from desktops to clusters of servers to mobile and edge devices.](https://www.tensorflow.org/)%7C