fresh install of QuTIP -> does not pass test

39 views
Skip to first unread message

Thierry Jolicoeur

unread,
Nov 4, 2022, 9:11:02 AM11/4/22
to QuTiP: Quantum Toolbox in Python
Hello,
I just installed QuTIP in a virtualenv on a Ubuntu box.
Here is the summary of the install:

QuTiP Version:      4.7.0
Numpy Version:      1.23.4
Scipy Version:      1.9.3
Cython Version:     0.29.32
Matplotlib Version: 3.6.2
Python Version:     3.8.10
Number of CPUs:     12
BLAS Info:          OPENBLAS
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Linux (x86_64)

the process went smoothly and I ran the test suite from IPython
then I got the following error
AttributeError: module 'numpy' has no attribute 'asscalar'

the full output is below, a bit verbose.
Any help is appreciated. Maybe this is harmless ?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-4b870e931db8> in <module>
----> 1 qutip.testing.run()

~/qutip/virt/lib/python3.8/site-packages/qutip/testing.py in run(full)
    26     if not full:
    27         test_options += ['-m', 'not slow']
---> 28     pytest.main(test_options + ["qutip"])
    29     # runs tests in qutip.tests module only
    30  

/usr/lib/python3/dist-packages/_pytest/config/__init__.py in main(args, plugins)
    61     try:
    62         try:
---> 63             config = _prepareconfig(args, plugins)
    64         except ConftestImportFailure as e:
    65             exc_info = ExceptionInfo(e.excinfo)

/usr/lib/python3/dist-packages/_pytest/config/__init__.py in _prepareconfig(args
, plugins)                                                                       
   204  
   205             _issue_warning_captured(warning, hook=config.hook, stackleve
l=4)
--> 206         return pluginmanager.hook.pytest_cmdline_parse(
   207             pluginmanager=pluginmanager, args=args                       
   208         )

/usr/lib/python3/dist-packages/pluggy/hooks.py in __call__(self, *args, **kwargs
)                                                                                
   284                     stacklevel=2,
   285                 )
--> 286         return self._hookexec(self, self.get_hookimpls(), kwargs)
   287  
   288     def call_historic(self, result_callback=None, kwargs=None, proc=None
):                                                                               

/usr/lib/python3/dist-packages/pluggy/manager.py in _hookexec(self, hook, method
s, kwargs)                                                                       
    90         # called from all hookcaller instances.
    91         # enable_tracing will set its own wrapping function at self._inn
er_hookexec                                                                      
---> 92         return self._inner_hookexec(hook, methods, kwargs)
    93  
    94     def register(self, plugin, name=None):

/usr/lib/python3/dist-packages/pluggy/manager.py in <lambda>(hook, methods, kwar
gs)                                                                              
    81             )
    82         self._implprefix = implprefix
---> 83         self._inner_hookexec = lambda hook, methods, kwargs: hook.multic
all(                                                                             
    84             methods,                                                     
    85             kwargs,

/usr/lib/python3/dist-packages/pluggy/callers.py in _multicall(hook_impls, calle
r_kwargs, firstresult)                                                           
   201         for gen in reversed(teardowns):
   202             try:
--> 203                 gen.send(outcome)
   204                 _raise_wrapfail(gen, "has second yield")
   205             except StopIteration:

/usr/lib/python3/dist-packages/_pytest/helpconfig.py in pytest_cmdline_parse()
    92 def pytest_cmdline_parse():
    93     outcome = yield
---> 94     config = outcome.get_result()
    95     if config.option.debug:
    96         path = os.path.abspath("pytestdebug.log")

/usr/lib/python3/dist-packages/pluggy/callers.py in get_result(self)
    78             ex = self._excinfo
    79             if _py3:
---> 80                 raise ex[1].with_traceback(ex[2])
    81             _reraise(*ex)  # noqa
    82  

/usr/lib/python3/dist-packages/pluggy/callers.py in _multicall(hook_impls, calle
r_kwargs, firstresult)                                                           
   185                         _raise_wrapfail(gen, "did not yield")
   186                 else:
--> 187                     res = hook_impl.function(*args)
   188                     if res is not None:
   189                         results.append(res)

/usr/lib/python3/dist-packages/_pytest/config/__init__.py in pytest_cmdline_pars
e(self, pluginmanager, args)                                                     
   737     def pytest_cmdline_parse(self, pluginmanager, args):
   738         try:
--> 739             self.parse(args)
   740         except UsageError:
   741  

/usr/lib/python3/dist-packages/_pytest/config/__init__.py in parse(self, args, a
ddopts)                                                                          
   945             kwargs=dict(pluginmanager=self.pluginmanager)
   946         )
--> 947         self._preparse(args, addopts=addopts)
   948         # XXX deprecated hook:
   949         self.hook.pytest_cmdline_preparse(config=self, args=args)

/usr/lib/python3/dist-packages/_pytest/config/__init__.py in _preparse(self, arg
s, addopts)                                                                      
   891             # Don't autoload from setuptools entry point. Only explicitl
y specified                                                                      
   892             # plugins are going to be loaded.
--> 893             self.pluginmanager.load_setuptools_entrypoints("pytest11")
   894         self.pluginmanager.consider_env()
   895         self.known_args_namespace = ns = self._parser.parse_known_args(

/usr/lib/python3/dist-packages/pluggy/manager.py in load_setuptools_entrypoints(
self, group, name)                                                               
   295                 ):
   296                     continue
--> 297                 plugin = ep.load()
   298                 self.register(plugin, name=ep.name)
   299                 self._plugin_distinfo.append((plugin, DistFacade(dist)))

/usr/lib/python3.8/importlib/metadata.py in load(self)
    75         """
    76         match = self.pattern.match(self.value)
---> 77         module = import_module(match.group('module'))
    78         attrs = filter(None, (match.group('attr') or '').split('.'))
    79         return functools.reduce(getattr, attrs, module)

/usr/lib/python3.8/importlib/__init__.py in import_module(name, package)
   125                 break
   126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
   128  
   129  

/usr/lib/python3.8/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/lib/python3.8/importlib/_bootstrap.py in _find_and_load(name, import_)

/usr/lib/python3.8/importlib/_bootstrap.py in _find_and_load_unlocked(name, impo
rt_)                                                                             

/usr/lib/python3.8/importlib/_bootstrap.py in _load_unlocked(spec)

/usr/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module)

/usr/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args
, **kwds)                                                                        

/usr/lib/python3/dist-packages/pytest_astropy_header/display.py in <module>
    22  
    23     from astropy import __version__ as astropy_version
---> 24     from astropy.tests.helper import ignore_warnings
    25     from astropy.utils.introspection import resolve_name
    26  

/usr/lib/python3/dist-packages/astropy/tests/helper.py in <module>
    22     pass
    23  
---> 24 from astropy.units import allclose as quantity_allclose  # noqa
    25 from astropy.utils.exceptions import (AstropyDeprecationWarning,
    26                                       AstropyPendingDeprecationWarning)

/usr/lib/python3/dist-packages/astropy/units/__init__.py in <module>
    15 # where most time is spent (e.g., using python -X importtime).
    16 from .core import *
---> 17 from .quantity import *
    18  
    19 from . import si

/usr/lib/python3/dist-packages/astropy/units/quantity.py in <module>
    27 from astropy.utils.data_info import ParentDtypeInfo
    28 from astropy import config as _config
---> 29 from .quantity_helper import (converters_and_unit, can_have_arbitrary_un
it,                                                                              
    30                               check_output)                              
    31 from .quantity_helper.function_helpers import (

/usr/lib/python3/dist-packages/astropy/units/quantity_helper/__init__.py in <mod
ule>                                                                             
     8 # By importing helpers, all the unit conversion functions needed for
     9 # numpy ufuncs and functions are defined.
---> 10 from . import helpers, function_helpers
    11 # For scipy.special and erfa, importing the helper modules ensures
    12 # the definitions are added as modules to UFUNC_HELPERS, to be loaded

/usr/lib/python3/dist-packages/astropy/units/quantity_helper/function_helpers.py
in <module>
   124 IGNORED_FUNCTIONS = {
   125     # Deprecated
--> 126     np.asscalar,
   127     # I/O - useless for Quantity, since no way to store the unit.
   128     np.save, np.savez, np.savetxt, np.savez_compressed,

~/qutip/virt/lib/python3.8/site-packages/numpy/__init__.py in __getattr__(attr)
   309             return Tester
   310  
--> 311         raise AttributeError("module {!r} has no attribute "
   312                              "{!r}".format(__name__, attr))              
   313  

AttributeError: module 'numpy' has no attribute 'asscalar'





Simon Cross

unread,
Nov 4, 2022, 10:57:47 AM11/4/22
to qu...@googlegroups.com
Hi Thierry,

I noticed in the last few frames of your traceback that the error is
actually coming from astropy!

It appears that what is happening is that QuTiP's tests are importing
pytest (reasonable). Pytest then runs the entry point hooks registered
for it (also reasonable). Astropy's hook tries to access np.asscalar,
which was removed in numpy 1.23.

Regards,
Simon

Thierry Jolicoeur

unread,
Nov 4, 2022, 11:39:34 AM11/4/22
to QuTiP: Quantum Toolbox in Python
I see. But I did not install astropy in the virtualenv. It is however present in my systemwide python stuff install.
I don't understand enough the virtual python stuff obviously.
for example within the virtualenv "pip uninstall astropy" says that astropy is not present.
anyway
thanks !
regards
Thierry

Simon Cross

unread,
Nov 4, 2022, 3:36:06 PM11/4/22
to qu...@googlegroups.com
Maybe your pytest is installed system wide?

Thierry Jolicoeur

unread,
Nov 5, 2022, 11:19:31 AM11/5/22
to QuTiP: Quantum Toolbox in Python
Hi Simon,
just solved the problem, I had a weird mixture of python2/python3 because I used virtualenv (which is python2) instead
of venv (which is python3 and I want only python3 now). Erasing everything, a fresh re-start and here we go.
test suite is fine now.
thanks a lot!
with best regards
Thierry

Simon Cross

unread,
Nov 5, 2022, 3:14:41 PM11/5/22
to qu...@googlegroups.com
Yay! Happy to help. :D
Reply all
Reply to author
Forward
0 new messages