dmici / NeuTomPy-toolbox

Python package for tomographic data processing and reconstruction
https://neutompy-toolbox.readthedocs.io/
GNU General Public License v3.0
30 stars 10 forks source link

AttributeError: module 'numpy' has no attribute 'nancumprod' #4

Closed othmanalbahri1 closed 3 years ago

othmanalbahri1 commented 3 years ago

Hello,

Thank you for developing NeuTomPy. I've enjoyed working with it!

I am trying to do a set of reconstructions on a AWS server (Ubuntu 20.04 Server). I followed the installation instructions. Note that the following step took nearly two hours to finish: conda install -c conda-forge ipython numpy numexpr matplotlib astropy tifffile opencv scikit-image read-roi mkl_fft scipy six tqdm pywavelets

I then tried to import NeuTomPy to test the installation: import numpy as np import neutompy as ntp

This results in the following error:

Traceback (most recent call last): File "fbp_gpu_reconstruction.py", line 6, in import neutompy as ntp File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/neutompy/init.py", line 20, in from .preproc.preproc import * File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/neutompy/preproc/preproc.py", line 7, in from skimage.transform import rotate File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/skimage/init.py", line 127, in from .util.dtype import (img_as_float32, File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/skimage/util/init.py", line 6, in from .apply_parallel import apply_parallel File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/skimage/util/apply_parallel.py", line 8, in import dask.array as da File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/dask/array/init.py", line 3, in from .core import ( File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/dask/array/core.py", line 22, in from . import chunk File "/home/othman/miniconda3/envs/neutompy_test/lib/python3.6/site-packages/dask/array/chunk.py", line 68, in nancumprod = np.nancumprod AttributeError: module 'numpy' has no attribute 'nancumprod'

I've managed to reproduce this error on my local machine (Ubuntu 20.04). However, on Google Colab notebooks, it works fine.

My initial guess is that an incompatible version of numpy is installed but I can't find a list of dependency versions in the documentation. I've tried re-installing numpy but that hasn't helped.

I've checked whether this is an issue with numpy itself but it is not. I installed numpy separately on a new conda environment and managed to call nancumprod without any issues.

>>> import numpy as np >>> np.nancumprod(1) array([1])

Here is a list of all the packages in this anaconda environment in which I run NeuTomPy:

packages in environment at /home/othman/miniconda3/envs/neutompy_test: Name Version Build Channel _libgcc_mutex 0.1 main
appdirs 1.4.4 pyh9f0ad1d_0 conda-forge astra-toolbox 1.8 np111py36_1 astra-toolbox astropy 3.0.5 py36h14c3975_1001 conda-forge atomicwrites 1.4.0 pyh9f0ad1d_0 conda-forge attrs 20.3.0 pyhd3deb0d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.1 py_0 conda-forge black 20.8b1 py_0 conda-forge blas 1.0 mkl
bzip2 1.0.8 h516909a_3 conda-forge ca-certificates 2020.10.14 0 anaconda cairo 1.16.0 h18b612c_1001 conda-forge certifi 2020.6.20 py36_0 anaconda click 7.1.2 pyh9f0ad1d_0 conda-forge cloudpickle 1.6.0 py_0 conda-forge cycler 0.10.0 py_2 conda-forge cytoolz 0.11.0 py36h1d69622_1 conda-forge dask-core 2.30.0 py_0 conda-forge dbus 1.13.6 he372182_0 conda-forge decorator 4.4.2 py_0 conda-forge expat 2.2.9 he1b5a44_2 conda-forge ffmpeg 4.0.2 ha0c5888_2 conda-forge fontconfig 2.13.1 he4413a7_1000 conda-forge freeglut 3.0.0 hf484d3e_1005 conda-forge freetype 2.10.4 h7ca028e_0 conda-forge glib 2.66.1 h92f7085_0
gmp 6.1.2 hf484d3e_1000 conda-forge gnutls 3.5.19 h2a4e5f8_1 conda-forge graphite2 1.3.13 h58526e2_1001 conda-forge gst-plugins-base 1.14.0 hbbd80ab_1
gstreamer 1.14.0 hb31296c_0
harfbuzz 1.8.8 hffaf4a1_0
hdf5 1.10.2 hc401514_3 conda-forge hypothesis 5.41.3 pyhd8ed1ab_0 conda-forge icu 58.2 hf484d3e_1000 conda-forge imageio 2.9.0 py_0 conda-forge importlib-metadata 3.1.0 pyhd8ed1ab_0 conda-forge importlib_metadata 3.1.0 hd8ed1ab_0 conda-forge intel-openmp 2020.2 254
ipython 7.16.1 py36h95af2a2_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jasper 2.0.14 h07fcdf6_1
jedi 0.17.2 py36h5fab9bb_1 conda-forge jpeg 9b h024ee3a_2
kiwisolver 1.3.1 py36h51d7077_0 conda-forge ld_impl_linux-64 2.33.1 h53a641e_7
libastra 1.8 0 astra-toolbox libblas 3.8.0 21_mkl conda-forge libcblas 3.8.0 21_mkl conda-forge libedit 3.1.20191231 h14c3975_1
libffi 3.3 he6710b0_2
libgcc-ng 9.1.0 hdf63c60_0
libgfortran 3.0.0 1 conda-forge libgfortran-ng 7.3.0 hdf63c60_0
libglu 9.0.0 he1b5a44_1001 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.8.0 21_mkl conda-forge libopencv 3.4.2 hb342d67_1
libpng 1.6.37 hbc83047_0
libstdcxx-ng 9.1.0 hdf63c60_0
libtiff 4.1.0 h2733197_1
libuuid 2.32.1 h14c3975_1000 conda-forge libxcb 1.13 h14c3975_1002 conda-forge libxml2 2.9.9 h13577e0_2 conda-forge lz4-c 1.9.2 heb0550a_3
matplotlib 3.1.0 py36_0 conda-forge matplotlib-base 3.1.0 py36h5f35d83_0 conda-forge mkl 2020.2 256
mkl-service 2.3.0 py36he904b0f_0
mkl_fft 1.0.10 py36_0 conda-forge more-itertools 8.6.0 pyhd8ed1ab_0 conda-forge mypy_extensions 0.4.3 py36h9f0ad1d_2 conda-forge ncurses 6.2 he6710b0_1
nettle 3.3 0 conda-forge networkx 2.5 py_0 conda-forge neutompy 1.0.10 pypi_0 pypi numexpr 2.6.9 py36h637b7d7_1000 conda-forge numpy 1.11.3 py36h7e9f1db_12
numpy-base 1.11.3 py36hde5b4d6_12
olefile 0.46 pyh9f0ad1d_1 conda-forge opencv 3.4.2 py36h6fd60c2_1
openh264 1.8.0 hdbcaa40_1000 conda-forge openssl 1.1.1h h7b6447c_0 anaconda parso 0.7.1 pyh9f0ad1d_0 conda-forge pathspec 0.8.1 pyhd3deb0d_0 conda-forge pcre 8.44 he1b5a44_0 conda-forge pexpect 4.8.0 pyh9f0ad1d_2 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 7.1.2 py36hb39fc2d_0
pip 20.2.4 py36h06a4308_0
pixman 0.38.0 h516909a_1003 conda-forge pluggy 0.13.1 py36h9880bd3_3 conda-forge prompt-toolkit 3.0.8 pyha770c72_0 conda-forge psutil 5.7.3 py36he6145b8_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.6.0 py_1001 conda-forge py 1.9.0 pyh9f0ad1d_0 conda-forge py-opencv 3.4.2 py36hb342d67_1
pygments 2.7.2 py_0 conda-forge pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyqt 5.9.2 py36hcca6a23_4 conda-forge pyqt5 5.15.2 pypi_0 pypi pyqt5-sip 12.8.1 pypi_0 pypi pytest 3.10.1 py36_1000 conda-forge pytest-arraydiff 0.3 py_0 conda-forge pytest-astropy 0.7.0 py_0 conda-forge pytest-astropy-header 0.1.2 py_0 conda-forge pytest-doctestplus 0.6.1 pyh9f0ad1d_0 conda-forge pytest-openfiles 0.4.0 py_0 conda-forge pytest-remotedata 0.3.2 pyh9f0ad1d_0 conda-forge python 3.6.12 hcff3b4d_2
python-dateutil 2.8.1 py_0 conda-forge python_abi 3.6 1_cp36m conda-forge pywavelets 1.0.3 py36hd352d35_1 conda-forge pyyaml 5.3.1 py36he6145b8_1 conda-forge qt 5.9.7 h5867ecd_1
read-roi 1.6.0 py_0 conda-forge readline 8.0 h7b6447c_0
regex 2020.11.13 py36h1d69622_0 conda-forge scikit-image 0.15.0 py36he1b5a44_0 conda-forge scipy 1.2.1 py36h09a28d5_1 conda-forge setuptools 50.3.1 py36h06a4308_1
simpleitk 2.0.1 py36hf484d3e_0 simpleitk sip 4.19.8 py36hf484d3e_1000 conda-forge six 1.15.0 pyh9f0ad1d_0 conda-forge sortedcontainers 2.3.0 pyhd8ed1ab_0 conda-forge sqlite 3.33.0 h62c20be_0
tifffile 0.15.1 py36h3010b51_1001 conda-forge tk 8.6.10 hbc83047_0
toml 0.10.2 pyhd8ed1ab_0 conda-forge toolz 0.11.1 py_0 conda-forge tornado 6.1 py36h1d69622_0 conda-forge tqdm 4.54.0 pyhd8ed1ab_0 conda-forge traitlets 4.3.3 py36h9f0ad1d_1 conda-forge typed-ast 1.4.1 py36h1d69622_1 conda-forge typing_extensions 3.7.4.3 py_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge wheel 0.35.1 pyhd3eb1b0_0
x264 1!152.20180806 h14c3975_0 conda-forge xorg-fixesproto 5.0 h14c3975_1002 conda-forge xorg-inputproto 2.3.2 h14c3975_1002 conda-forge xorg-kbproto 1.0.7 h14c3975_1002 conda-forge xorg-libice 1.0.10 h516909a_0 conda-forge xorg-libsm 1.2.3 h84519dc_1000 conda-forge xorg-libx11 1.6.12 h516909a_0 conda-forge xorg-libxau 1.0.9 h14c3975_0 conda-forge xorg-libxdmcp 1.1.3 h516909a_0 conda-forge xorg-libxext 1.3.4 h516909a_0 conda-forge xorg-libxfixes 5.0.3 h516909a_1004 conda-forge xorg-libxi 1.7.10 h516909a_0 conda-forge xorg-libxrender 0.9.10 h516909a_1002 conda-forge xorg-renderproto 0.11.1 h14c3975_1002 conda-forge xorg-xextproto 7.3.0 h14c3975_1002 conda-forge xorg-xproto 7.0.31 h14c3975_1007 conda-forge xz 5.2.5 h7b6447c_0
yaml 0.2.5 h516909a_0 conda-forge zipp 3.4.0 py_0 conda-forge zlib 1.2.11 h7b6447c_3
zstd 1.4.5 h9ceee32_0

I'd appreciate your thoughts on this.

Also, if you have a working anaconda environment, would you mind sharing your yml file?

Thanks,

Othman

dmici commented 3 years ago

Dear Othman,

the error is related to the numpy version 1.11.3 installed in your environment. The function nancumprod was introduced in numpy version 1.12.0.

This issue can be solved by upgrading numpy:

conda remove --force numpy 
pip install -U numpy

I noticed the installation failure of the dependencies from conda-forge and the installation procedure was updated in the documentation to fix this issue.

Thank you for contribution!