CERN/TIGRE

TIGRE - trouble using TIGRE for Python

martassimoes opened this issue · 5 comments

Hi.
When I try to import the 'tigre' module in Python version 1.19, I encounter this error:

cannot import name 'int' from 'numpy' (C:\Users\ASUS\anaconda3\lib\site-packages\numpy_init_.py)

However, I have already updated and downgraded to other versions, and a different error still appears: .

numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Has anyone else experienced this?

You mean numpy version 1.19?
Can you tell exactly which versions you are using? including of TIGRE? This issue should have been fixed a bit ago (#430)

You mean numpy version 1.19?

yes.

I assumed. Can you tell us python, cython and TIGRE version you are running? as mentioned, I thought this was solved already, so maybe you are running an old version.

Its also strange, because np.int was deprecated in numpy 1.20, but you say you are running 1.19, so I am not sure where the error comes from, as I can't see anywhere in TIGRE using np.int (maybe I am missing something!) nor should it error in numpy 1.19, if there was anywhere.

Hi.
When I run the code in demo 3, point 6 of the step-by-step instructions in the Installation Instructions for Python for Windows section, I get the following error:

ImportError Traceback (most recent call last)
in
----> 1 import tigre
2 import numpy as np
3 from tigre.utilities import sample_loader
4 from tigre.utilities import CTnoise
5

~\anaconda3\lib\site-packages\tigre_init_.py in
28 from .utilities.visualization.plot_angles import plot_angles
29 from .utilities.CTnoise import add
---> 30 from .utilities.common_geometry import staticDetectorGeo, staticDetLinearSourceGeo, ArbitrarySourceDetMoveGeo
31
32 from . import algorithms

~\anaconda3\lib\site-packages\tigre\utilities\common_geometry.py in
1 import numpy as np
2 import copy
----> 3 from scipy.spatial.transform import Rotation
4 from .geometry import Geometry
5

~\anaconda3\lib\site-packages\scipy\spatial_init_.py in
100 from ._plotutils import *
101 from ._procrustes import procrustes
--> 102 from .geometric_slerp import geometric_slerp
103
104 all = [s for s in dir() if not s.startswith('
')]

~\anaconda3\lib\site-packages\scipy\spatial_geometric_slerp.py in
6
7 import numpy as np
----> 8 from scipy.spatial.distance import euclidean
9
10

~\anaconda3\lib\site-packages\scipy\spatial\distance.py in
119 from . import _hausdorff
120 from ..linalg import norm
--> 121 from ..special import rel_entr
122
123

~\anaconda3\lib\site-packages\scipy\special_init_.py in
634 from ._ufuncs import *
635
--> 636 from . import _basic
637 from ._basic import *
638

~\anaconda3\lib\site-packages\scipy\special_basic.py in
14 poch, binom, hyp0f1)
15 from . import specfun
---> 16 from . import orthogonal
17 from ._comb import _comb_int
18

~\anaconda3\lib\site-packages\scipy\special\orthogonal.py in
77 # SciPy imports.
78 import numpy as np
---> 79 from numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,
80 hstack, arccos, arange)
81 from scipy import linalg

ImportError: cannot import name 'int' from 'numpy' (C:\Users\ASUS\anaconda3\lib\site-packages\numpy_init_.py)

This is for numpy version 1.19.

When I upgrade to numpy 1.20, or downgrade to lower versions of numpy, I always get the same error:

ValueError Traceback (most recent call last)
in
----> 1 import tigre
2 import numpy as np
3 from tigre.utilities import sample_loader
4 from tigre.utilities import CTnoise
5

~\anaconda3\lib\site-packages\tigre_init_.py in
21 from .utilities.geometry import geometry
22 from .utilities.geometry_default import ConeGeometryDefault as geometry_default
---> 23 from .utilities.Ax import Ax
24 from .utilities.Atb import Atb
25 from .utilities.visualization.plotproj import plotproj, plotProj, plotSinogram

~\anaconda3\lib\site-packages\tigre\utilities\Ax.py in
2
3 import numpy as np
----> 4 from _Ax import _Ax_ext
5
6 from .gpu import GpuIds

~\anaconda3\lib\site-packages\tigre\utilities\cuda_interface_Ax.pyx in init _Ax()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject.

Has anyone else experienced this?

As I said in my email, the error before

ImportError: cannot import name 'int' from 'numpy' (C:\Users\ASUS\anaconda3\lib\site-packages\numpy_init_.py)

is because you are using a numpy that doesn't have np.int (i.e. you are not using 1.19 as you think you are), as Scipy errors. Clearly also your Scipy and numpy are not compatible. This is likely because you have been fiddling with versions too much and you have lost control of which one you have.

The second error

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject.

Suggests that the binary (compiled files after pip install .) are not compatible with the current version. This almost surely happens because you did pip install . for one version of numpy/scipy etc, but you did then change them, thus the binary file is incompatible.