Issue using pylinac with python 3.8.10

Hello everybody,

I’m a beginner and I would like to try pylinac. The issue is that when I want to try any demo, I get the following error:

Traceback (most recent call last):
File “c:\Users\ben-abdellah-aghzout\Code\testlib.py”, line 1, in
from pylinac import PicketFence
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac_init_.py”, line 12, in
from .acr import ACRCT, ACRMRILarge
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\acr.py”, line 24, in
from .ct import (
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\ct.py”, line 46, in
from .core.nps import (
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\core\nps.py”, line 122, in
def plot_nps1d(nps1d: np.ndarray, ax: Axis | None = None) → Axis:
TypeError: unsupported operand type(s) for |: ‘type’ and ‘NoneType’
PS C:\Users\ben-abdellah-aghzout\Code> python -u “c:\Users\ben-abdellah-aghzout\Code\testlib.py”
Traceback (most recent call last):
File “c:\Users\ben-abdellah-aghzout\Code\testlib.py”, line 1, in
from pylinac import CatPhan504
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac_init_.py”, line 12, in
from .acr import ACRCT, ACRMRILarge
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\acr.py”, line 24, in
from .ct import (
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\ct.py”, line 46, in
from .core.nps import (
File “C:\Users\ben-abdellah-aghzout\AppData\Local\Programs\Python\Python38\lib\site-packages\pylinac\core\nps.py”, line 122, in
def plot_nps1d(nps1d: np.ndarray, ax: Axis | None = None) → Axis:
TypeError: unsupported operand type(s) for |: ‘type’ and ‘NoneType’

I tried to find the issue and it appears that it might be because I’m running python 3.8. Isn’t pylinac compatible with every python 3.x version ?

Thank you for your help,
Safir

Hi,
Python 3.8 will be “end of life” in half a year. According to github you need at least python 3.9 but as far as I was able find out the operand “|” got introduced with 3.10.
If you need to stick with python 3.8 you should at least be able to run pylinac 3.13 (that is the last version with support for python 3.7)

regards
Thomas

Hello Thomas,

Thank you for this valuable comment :slight_smile:

Ah, unfortunately that wasn’t caught in our CI/CD. It is meant to be compatible with all Python versions that are not past end of life. I will add a fix. As stated though, using a newer version of python is the workaround.