amarquand / PCNtoolkit

Toolbox for normative modelling and spatial inference of neuroimaging data. https://pcntoolkit.readthedocs.io/en/latest/
GNU General Public License v3.0
113 stars 50 forks source link

ImportError: cannot import name 'asscalar' from 'numpy' #109

Closed zapaishchykova closed 1 year ago

zapaishchykova commented 1 year ago

Hello! I've created a conda enviroment on Linux ubuntu 22.04 with Python 3.8.3. First my glob3 installation failed, so I did: sudo pip install glob2.

(gamlss) $ python -c "import pcntoolkit as pk;print(pk.__file__)"
Traceback (most recent call last):
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/gp.py", line 15, in <module>
    from pcntoolkit.util.utils import squared_dist
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/__init__.py", line 1, in <module>
    from . import utils
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/utils.py", line 17, in <module>
    import pymc3 as pm
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 41, in <module>
    from .distributions import *
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/__init__.py", line 15, in <module>
    from . import timeseries
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/timeseries.py", line 22, in <module>
    from pymc3.util import get_variable_name
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/util.py", line 21, in <module>
    from numpy import asscalar, ndarray
ImportError: cannot import name 'asscalar' from 'numpy' (/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/numpy/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/trendsurf.py", line 21, in <module>
    from pcntoolkit.model.bayesreg import BLR
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/__init__.py", line 2, in <module>
    from . import gp
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/gp.py", line 25, in <module>
    from util.utils import squared_dist
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/__init__.py", line 1, in <module>
    from . import utils
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/utils.py", line 17, in <module>
    import pymc3 as pm
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 41, in <module>
    from .distributions import *
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/__init__.py", line 15, in <module>
    from . import timeseries
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/timeseries.py", line 22, in <module>
    from pymc3.util import get_variable_name
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/util.py", line 21, in <module>
    from numpy import asscalar, ndarray
ImportError: cannot import name 'asscalar' from 'numpy' (/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/numpy/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/gp.py", line 15, in <module>
    from pcntoolkit.util.utils import squared_dist
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/__init__.py", line 1, in <module>
    from . import utils
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/utils.py", line 17, in <module>
    import pymc3 as pm
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 41, in <module>
    from .distributions import *
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/__init__.py", line 15, in <module>
    from . import timeseries
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/timeseries.py", line 22, in <module>
    from pymc3.util import get_variable_name
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/util.py", line 21, in <module>
    from numpy import asscalar, ndarray
ImportError: cannot import name 'asscalar' from 'numpy' (/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/numpy/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/__init__.py", line 1, in <module>
    from . import trendsurf
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/trendsurf.py", line 30, in <module>
    from model.bayesreg import BLR
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/__init__.py", line 2, in <module>
    from . import gp
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/gp.py", line 25, in <module>
    from util.utils import squared_dist
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/__init__.py", line 1, in <module>
    from . import utils
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/utils.py", line 17, in <module>
    import pymc3 as pm
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 41, in <module>
    from .distributions import *
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/__init__.py", line 15, in <module>
    from . import timeseries
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/distributions/timeseries.py", line 22, in <module>
    from pymc3.util import get_variable_name
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/util.py", line 21, in <module>
    from numpy import asscalar, ndarray
ImportError: cannot import name 'asscalar' from 'numpy' (/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/numpy/__init__.py)
zapaishchykova commented 1 year ago

and when I tried to install with pip, here is the tracelog:

$ python -c "import pcntoolkit as pk;print(pk.__file__)"
Traceback (most recent call last):
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/configparser.py", line 168, in fetch_val_for_key
    return theano_cfg.get(section, option)
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/configparser.py", line 1149, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'blas'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/configparser.py", line 327, in __get__
    val_str = fetch_val_for_key(self.fullname,
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/configparser.py", line 172, in fetch_val_for_key
    raise KeyError(key)
KeyError: 'blas.ldflags'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/__init__.py", line 1, in <module>
    from . import trendsurf
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/trendsurf.py", line 21, in <module>
    from pcntoolkit.model.bayesreg import BLR
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/__init__.py", line 2, in <module>
    from . import gp
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/model/gp.py", line 15, in <module>
    from pcntoolkit.util.utils import squared_dist
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/__init__.py", line 1, in <module>
    from . import utils
  File "/media/sda/Anna/PCNtoolkit/pcntoolkit/util/utils.py", line 17, in <module>
    import pymc3 as pm
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 38, in <module>
    __set_compiler_flags()
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/pymc3-3.9.3-py3.8.egg/pymc3/__init__.py", line 33, in __set_compiler_flags
    import theano
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/__init__.py", line 124, in <module>
    from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/scan_module/__init__.py", line 41, in <module>
    from theano.scan_module import scan_opt
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/scan_module/scan_opt.py", line 60, in <module>
    from theano import tensor, scalar
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/tensor/__init__.py", line 17, in <module>
    from theano.tensor import blas
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/tensor/blas.py", line 155, in <module>
    from theano.tensor.blas_headers import blas_header_text
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/tensor/blas_headers.py", line 987, in <module>
    if not config.blas.ldflags:
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/configparser.py", line 332, in __get__
    val_str = self.default()
  File "/home/user/anaconda3/envs/gamlss/lib/python3.8/site-packages/Theano-1.0.5-py3.8.egg/theano/configdefaults.py", line 1284, in default_blas_ldflags
    blas_info = np.distutils.__config__.blas_opt_info
AttributeError: module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'
jerke123 commented 1 year ago

I had the same error, try downgrading to numpy 1.20.3: pip install --upgrade numpy==1.20.3 source - https://stackoverflow.com/questions/70839312/module-numpy-distutils-config-has-no-attribute-blas-opt-info

amarquand commented 1 year ago

Hi - this issue has been fixed with the newest release of the toolbox (0.28). Note that this was a major migration so not all of our tutorials will work at the moment, but we will update them in the coming weeks. Thanks for your patience!