This is a module that was introduced in python 3.10, and so naturally the import fails in python 3.9:
[twi18192@pc0074 ~]$ module load python/3.9
Loading 64-bit Anaconda Python3, version 3.9
If there are any problems, please contact dataanalysis@diamond.ac.uk
Need a 3rd party Python package installing? First, consider using the
user-based install option of pip to test it. (I.e., use
$ pip install --user ... For further details, see $ pip help install)
This will install the package in ~/.local
Please read https://confluence.diamond.ac.uk/x/rKDIAw for other options.
If a site-wide installation is required, contact Data Analysis.
For further details, see $ pip help install
Loading python/3.9
Loading requirement: global/directories
(python3.9) [twi18192@pc0074 ~]$ python --version
Python 3.9.1
(python3.9) [twi18192@pc0074 ~]$ python
Python 3.9.1 | packaged by conda-forge | (default, Jan 26 2021, 01:34:10)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import TypeAlias
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TypeAlias' from 'typing' (/dls_sw/apps/python/anaconda/4.6.14/64/envs/python3.9/lib/python3.9/typing.py)
but works in python 3.10:
[twi18192@pc0074 ~]$ module load python/3.10
Loading a conda environment for Python 3.10
***********************************************************
This is now the default Python environment
If there are any problems or packages missing compared with
Python 3.7, please contact dataanalysis@diamond.ac.uk
***********************************************************
Need a 3rd party Python package installing? First, consider using the
user-based install option of pip to test it. (I.e., use
$ pip install --user ... For further details, see $ pip help install)
This will install the package in ~/.local
Please read https://confluence.diamond.ac.uk/x/rKDIAw for other options.
If a site-wide installation is required, contact Data Analysis.
Loading python/3.10
Loading requirement: global/directories
(python3.10) [twi18192@pc0074 ~]$ python --version
Python 3.10.12
(python3.10) [twi18192@pc0074 ~]$ python
Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import TypeAlias
>>> TypeAlias
typing.TypeAlias
There are maybe other reasons for the code to not be backwards compatible with python 3.9, but the first one that arises when trying to run
python -m httomo --help
is the importTypeAlias
import that is inyaml_checker.py
: https://github.com/DiamondLightSource/httomo/blob/4429711ab89ed1efe86d9c3be260df25fc7f1999/httomo/yaml_checker.py#L6This is a module that was introduced in python 3.10, and so naturally the import fails in python 3.9:
but works in python 3.10:
There are several places in the repo where we cite python 3.9 compatibility, such as in the
conda_build_config.yaml
(used when building the conda package): https://github.com/DiamondLightSource/httomo/blob/4429711ab89ed1efe86d9c3be260df25fc7f1999/conda/recipe/conda_build_config.yaml#L1-L3and
pyproject.toml
(used in bothpip install
andconda install
): https://github.com/DiamondLightSource/httomo/blob/4429711ab89ed1efe86d9c3be260df25fc7f1999/pyproject.toml#L45 https://github.com/DiamondLightSource/httomo/blob/4429711ab89ed1efe86d9c3be260df25fc7f1999/pyproject.toml#L48 https://github.com/DiamondLightSource/httomo/blob/4429711ab89ed1efe86d9c3be260df25fc7f1999/pyproject.toml#L102