Python Forum
IPython errors for numpy array min/max methods - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: IPython errors for numpy array min/max methods (/thread-41050.html)



IPython errors for numpy array min/max methods - muelaner - Nov-04-2023

I'm using the IPython console (v 8.12.0) in Anaconda and getting some error messages I don't understand when accessing basic methods of numpy arrays. If I use the same commands in IDLE then I don't get any errors. For example, I enter the following in IPython console and get this:

import numpy as np
a = np.linspace(1,36,36).reshape(12,3)
a.min()
Out: 1.0
Error:
[SpyderKernelApp] ERROR | Exception in message handler: Traceback (most recent call last): File "C:\Users\jody\anaconda3\Lib\site-packages\ipykernel\kernelbase.py", line 406, in dispatch_shell await result File "C:\Users\jody\anaconda3\Lib\site-packages\ipykernel\kernelbase.py", line 796, in inspect_request reply_content = self.do_inspect( ^^^^^^^^^^^^^^^^ File "C:\Users\jody\anaconda3\Lib\site-packages\ipykernel\ipkernel.py", line 544, in do_inspect bundle = self.shell.object_inspect_mime( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jody\anaconda3\Lib\site-packages\IPython\core\interactiveshell.py", line 1838, in object_inspect_mime return self.inspector._get_info( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jody\anaconda3\Lib\site-packages\IPython\core\oinspect.py", line 738, in _get_info info_dict = self.info(obj, oname=oname, info=info, detail_level=detail_level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jody\anaconda3\Lib\site-packages\IPython\core\oinspect.py", line 838, in info if info and info.parent and hasattr(info.parent, HOOK_NAME): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()



RE: IPython errors for numpy array min/max methods - snippsat - Nov-04-2023

Test from command line and remember most always activate a environment when work with Anaconda.
(base) is the one if not have make own.
 C:\anaconda3\Scripts
λ activate base

C:\anaconda3\Scripts
(base) λ ipython --version
8.15.0

C:\anaconda3\Scripts
(base) λ ipython
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:16:22) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.15.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import numpy as np

In [2]: a = np.linspace(1,36,36).reshape(12,3)

In [3]: a.min()
Out[3]: 1.0
So if work here it's Spyder IPython Console(has own Kernel) that has the problem.
Can of course uninstall Ipython and Spyder and try reinstall or try update conda and Anaconda.

The easier way and what would suggest to use i a always use is a own environment.
This will make a basic environment and also download new version of Python 3.11.5.
conda create --name my_env -c conda-forge spyder jupyterlab pandas python=3.11.5
Activate (my_env) and start Spyder from environment then i guess all will work fine.