spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.37k stars 1.62k forks source link

Variable explorer not working due to incompatibility between Numpy 2 and 1 #22842

Open ingo-m opened 3 weeks ago

ingo-m commented 3 weeks ago

Issue Report Checklist

Problem Description

For years, I always installed spyder directly into conda envs, no problem. However, since I switched to Ubuntu 24 (with wayland) that does not work anymore (see https://github.com/spyder-ide/spyder/issues/22219).

So instead, I installed the spyder deb package (currently spyder 5.5.1):

sudo apt-get install spyder

I also installed numpy & pandas in the system python env (not sure whether this was necessary):

sudo apt-get install python3-numpy python3-pandas python3-ipython

But now I cannot inspect objects (such as numpy arrays and pandas dataframes) from the variable explorer anymore ("Spyder was unable to retrieve the value of this variable from the console.").

More specifically, I can inspect numpy arrays and dataframes from the variable explorer when using spyder's default python interpreter (presumably system python), but not when using a conda env.

Now that's not ideal, because obviously for interactive python development I need to use my project's conda env with all relevant packages, not system python.

I'm aware of https://github.com/spyder-ide/spyder/issues/22784 and that there might be a mismatch between system python and the conda env, but the question is how to solve this?

Is there any way to get the variable explorer to work after installing spyder as a deb package (which, again, is the only way to get spyder to work under Ubuntu 24 & wayland AFAIK)?

Versions

This is from the "About Spyder" menu (referring to system python):

Ubuntu 24.04.1 LTS

My conda env is using python 3.12.7

Conda env packages (spyder python interpreter is configured to use this env) ``` # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge aiohappyeyeballs 2.4.3 pypi_0 pypi aiohttp 3.10.10 pypi_0 pypi aiosignal 1.3.1 pypi_0 pypi altair 5.4.1 pypi_0 pypi anyio 4.6.2.post1 pypi_0 pypi asttokens 2.4.1 pypi_0 pypi asyncpg 0.30.0 pypi_0 pypi attrs 24.2.0 pypi_0 pypi authlib 1.3.2 pypi_0 pypi blinker 1.8.2 pypi_0 pypi blosc2 2.7.1 pypi_0 pypi boto3 1.35.54 pypi_0 pypi botocore 1.35.54 pypi_0 pypi bzip2 1.0.8 h4bc722e_7 conda-forge ca-certificates 2024.8.30 hbcca054_0 conda-forge cachetools 5.5.0 pypi_0 pypi certifi 2024.8.30 pyhd8ed1ab_0 conda-forge cffi 1.17.1 pypi_0 pypi charset-normalizer 3.4.0 pypi_0 pypi click 8.1.7 pypi_0 pypi cloudpickle 3.1.0 pypi_0 pypi comm 0.2.2 pypi_0 pypi contourpy 1.3.0 pypi_0 pypi cryptography 43.0.3 pypi_0 pypi cycler 0.12.1 pypi_0 pypi debugpy 1.8.7 pypi_0 pypi decorator 5.1.1 pypi_0 pypi diffusers 0.31.0 pypi_0 pypi distlib 0.3.9 pyhd8ed1ab_0 conda-forge distro 1.9.0 pypi_0 pypi dnspython 2.7.0 pypi_0 pypi executing 2.1.0 pypi_0 pypi fastapi 0.115.4 pypi_0 pypi filelock 3.16.1 pyhd8ed1ab_0 conda-forge flatbuffers 24.3.25 pypi_0 pypi fonttools 4.54.1 pypi_0 pypi frozenlist 1.5.0 pypi_0 pypi fsspec 2024.10.0 pypi_0 pypi geoip2 4.8.0 pypi_0 pypi gitdb 4.0.11 pypi_0 pypi gitpython 3.1.43 pypi_0 pypi google-api-core 2.22.0 pypi_0 pypi google-api-python-client 2.151.0 pypi_0 pypi google-auth 2.35.0 pypi_0 pypi google-auth-httplib2 0.2.0 pypi_0 pypi google-search-results 2.4.2 pypi_0 pypi googleapis-common-protos 1.65.0 pypi_0 pypi greenlet 3.1.1 pypi_0 pypi h11 0.14.0 pypi_0 pypi html2image 2.0.5 pypi_0 pypi httpcore 1.0.6 pypi_0 pypi httplib2 0.22.0 pypi_0 pypi httpx 0.27.2 pypi_0 pypi huggingface-hub 0.26.2 pypi_0 pypi idna 3.10 pypi_0 pypi imageio 2.36.0 pypi_0 pypi importlib-metadata 8.5.0 pypi_0 pypi ipykernel 6.29.5 pypi_0 pypi ipython 8.29.0 pypi_0 pypi jedi 0.19.1 pypi_0 pypi jinja2 3.1.4 pypi_0 pypi jiter 0.7.0 pypi_0 pypi jmespath 1.0.1 pypi_0 pypi joblib 1.4.2 pypi_0 pypi jsonschema 4.23.0 pypi_0 pypi jsonschema-specifications 2024.10.1 pypi_0 pypi jupyter-client 8.6.3 pypi_0 pypi jupyter-core 5.7.2 pypi_0 pypi kiwisolver 1.4.7 pypi_0 pypi ld_impl_linux-64 2.43 h712a8e2_2 conda-forge libexpat 2.6.3 h5888daf_0 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc 14.2.0 h77fa898_1 conda-forge libgcc-ng 14.2.0 h69a702a_1 conda-forge libgomp 14.2.0 h77fa898_1 conda-forge libnsl 2.0.1 hd590300_0 conda-forge libsqlite 3.47.0 hadc24fc_1 conda-forge libuuid 2.38.1 h0b41bf4_0 conda-forge libxcrypt 4.4.36 hd590300_1 conda-forge libzlib 1.3.1 hb9d3cd8_2 conda-forge mangum 0.19.0 pypi_0 pypi markdown-it-py 3.0.0 pypi_0 pypi markupsafe 3.0.2 pypi_0 pypi matplotlib 3.9.2 pypi_0 pypi matplotlib-inline 0.1.7 pypi_0 pypi maxminddb 2.6.2 pypi_0 pypi mdurl 0.1.2 pypi_0 pypi mpmath 1.3.0 pypi_0 pypi msgpack 1.1.0 pypi_0 pypi multidict 6.1.0 pypi_0 pypi narwhals 1.13.1 pypi_0 pypi ncurses 6.5 he02047a_1 conda-forge ndindex 1.9.2 pypi_0 pypi nest-asyncio 1.6.0 pypi_0 pypi networkx 3.4.2 pypi_0 pypi numexpr 2.10.1 pypi_0 pypi numpy 2.1.3 pypi_0 pypi nvidia-cublas-cu12 12.4.5.8 pypi_0 pypi nvidia-cuda-cupti-cu12 12.4.127 pypi_0 pypi nvidia-cuda-nvrtc-cu12 12.4.127 pypi_0 pypi nvidia-cuda-runtime-cu12 12.4.127 pypi_0 pypi nvidia-cudnn-cu12 9.1.0.70 pypi_0 pypi nvidia-cufft-cu12 11.2.1.3 pypi_0 pypi nvidia-curand-cu12 10.3.5.147 pypi_0 pypi nvidia-cusolver-cu12 11.6.1.9 pypi_0 pypi nvidia-cusparse-cu12 12.3.1.170 pypi_0 pypi nvidia-nccl-cu12 2.21.5 pypi_0 pypi nvidia-nvjitlink-cu12 12.4.127 pypi_0 pypi nvidia-nvtx-cu12 12.4.127 pypi_0 pypi ollama 0.3.3 pypi_0 pypi openai 1.53.0 pypi_0 pypi openssl 3.3.2 hb9d3cd8_0 conda-forge packaging 24.1 pyhd8ed1ab_0 conda-forge pandas 2.2.3 pypi_0 pypi parso 0.8.4 pypi_0 pypi pexpect 4.9.0 pypi_0 pypi pillow 10.4.0 pypi_0 pypi pip 24.3.1 pyh8b19718_0 conda-forge pipenv 2024.3.1 pyhd8ed1ab_0 conda-forge platformdirs 4.3.6 pyhd8ed1ab_0 conda-forge plotly 5.24.1 pypi_0 pypi prompt-toolkit 3.0.48 pypi_0 pypi propcache 0.2.0 pypi_0 pypi proto-plus 1.25.0 pypi_0 pypi protobuf 5.28.3 pypi_0 pypi psutil 6.1.0 pypi_0 pypi psycopg2-binary 2.9.10 pypi_0 pypi ptyprocess 0.7.0 pypi_0 pypi pure-eval 0.2.3 pypi_0 pypi py-cpuinfo 9.0.0 pypi_0 pypi pyarrow 18.0.0 pypi_0 pypi pyasn1 0.6.1 pypi_0 pypi pyasn1-modules 0.4.1 pypi_0 pypi pycparser 2.22 pypi_0 pypi pydantic 1.10.18 pypi_0 pypi pydeck 0.9.1 pypi_0 pypi pygments 2.18.0 pypi_0 pypi pygtail 0.14.0 pypi_0 pypi pymongo 4.10.1 pypi_0 pypi pyparsing 3.2.0 pypi_0 pypi python 3.12.7 hc5c86c4_0_cpython conda-forge python-dateutil 2.9.0.post0 pypi_0 pypi python-dotenv 1.0.1 pypi_0 pypi pytz 2024.2 pypi_0 pypi pyyaml 6.0.2 pypi_0 pypi pyzmq 26.2.0 pypi_0 pypi readline 8.2 h8228510_1 conda-forge redis 5.2.0 pypi_0 pypi referencing 0.35.1 pypi_0 pypi regex 2024.9.11 pypi_0 pypi requests 2.32.3 pypi_0 pypi requests-file 2.1.0 pypi_0 pypi rich 13.9.4 pypi_0 pypi rpds-py 0.20.1 pypi_0 pypi rq 2.0.0 pypi_0 pypi rsa 4.9 pypi_0 pypi ruff 0.7.2 pypi_0 pypi s3transfer 0.10.3 pypi_0 pypi safetensors 0.4.5 pypi_0 pypi scikit-learn 1.5.2 pypi_0 pypi scipy 1.14.1 pypi_0 pypi seaborn 0.13.2 pypi_0 pypi sentence-transformers 3.2.1 pypi_0 pypi setuptools 75.3.0 pyhd8ed1ab_0 conda-forge six 1.16.0 pypi_0 pypi smmap 5.0.1 pypi_0 pypi sniffio 1.3.1 pypi_0 pypi spyder-kernels 2.5.0 pypi_0 pypi sqlalchemy 2.0.36 pypi_0 pypi stack-data 0.6.3 pypi_0 pypi starlette 0.41.2 pypi_0 pypi streamlit 1.39.0 pypi_0 pypi stripe 11.2.0 pypi_0 pypi sympy 1.13.1 pypi_0 pypi tables 3.10.1 pypi_0 pypi tenacity 9.0.0 pypi_0 pypi threadpoolctl 3.5.0 pypi_0 pypi tiktoken 0.8.0 pypi_0 pypi tilemapbase 0.4.7 pypi_0 pypi tk 8.6.13 noxft_h4845f30_101 conda-forge tldextract 5.1.2 pypi_0 pypi tokenizers 0.20.1 pypi_0 pypi toml 0.10.2 pypi_0 pypi torch 2.5.1 pypi_0 pypi tornado 6.4.1 pypi_0 pypi tqdm 4.66.6 pypi_0 pypi traitlets 5.14.3 pypi_0 pypi transformers 4.46.1 pypi_0 pypi triton 3.1.0 pypi_0 pypi typing-extensions 4.12.2 pypi_0 pypi tzdata 2024.2 pypi_0 pypi tzlocal 5.2 pypi_0 pypi uritemplate 4.1.1 pypi_0 pypi urllib3 2.2.3 pypi_0 pypi uvicorn 0.32.0 pypi_0 pypi virtualenv 20.27.1 pyhd8ed1ab_0 conda-forge watchdog 5.0.3 pypi_0 pypi wcwidth 0.2.13 pypi_0 pypi webdriver-manager 4.0.2 pypi_0 pypi websocket-client 1.8.0 pypi_0 pypi wheel 0.44.0 pyhd8ed1ab_0 conda-forge wurlitzer 3.1.1 pypi_0 pypi xz 5.2.6 h166bdaf_0 conda-forge yarl 1.17.1 pypi_0 pypi zipp 3.20.2 pypi_0 pypi ```

Dependencies

Spyder dependencies ``` # Mandatory: atomicwrites >=1.2.0 : 1.4.1 (OK) chardet >=2.0.0 : 5.2.0 (OK) cloudpickle >=0.5.0 : 3.0.0 (OK) cookiecutter >=1.6.0 : 2.6.0 (OK) diff_match_patch >=20181111 : 20230430 (OK) intervaltree >=3.0.2 : 3.0.2 (OK) IPython >=8.13.0,<9.0.0,!=8.17.1 : 8.20.0 (OK) jedi >=0.17.2,<0.20.0 : 0.19.1 (OK) jellyfish >=0.7 : 0.10.0 (OK) jsonschema >=3.2.0 : 4.10.3 (OK) keyring >=17.0.0 : 24.3.1 (OK) nbconvert >=4.0 : 6.5.3 (OK) numpydoc >=0.6.0 : 1.6.0 (OK) parso >=0.7.0,<0.9.0 : 0.8.3 (OK) pexpect >=4.4.0 : 4.9.0 (OK) pickleshare >=0.4 : 0.7.5 (OK) psutil >=5.3 : 5.9.8 (OK) pygments >=2.0 : 2.17.2 (OK) pylint >=2.5.0,<3.1 : 3.0.3 (OK) pylint_venv >=3.0.2 : 3.0.2 (OK) pyls_spyder >=0.4.0 : 0.4.0 (OK) pylsp >=1.10.0,<1.11.0 : 1.10.0 (OK) pylsp_black >=2.0.0,<3.0.0 : 2.0.0 (OK) qdarkstyle >=3.2.0,<3.3.0 : 3.2.3 (OK) qstylizer >=0.2.2 : 0.2.2 (OK) qtawesome >=1.2.1 : 1.2.3 (OK) qtconsole >=5.5.1,<5.6.0 : 5.5.1 (OK) qtpy >=2.1.0 : 2.4.1 (OK) rtree >=0.9.7 : 1.2.0 (OK) setuptools >=49.6.0 : 68.1.2 (OK) sphinx >=0.6.6 : 7.2.6 (OK) spyder_kernels >=2.5.0,<2.6.0 : 2.5.0 (OK) textdistance >=4.2.0 : 4.6.0 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 3.0.0 (OK) xdg >=0.26 : 0.28 (OK) zmq >=22.1.0 : 24.0.1 (OK) # Optional: cython >=0.21 : None (NOK) matplotlib >=3.0.0 : 3.6.3 (OK) numpy >=1.7 : 1.26.4 (OK) pandas >=1.1.1 : 2.1.4 (OK) scipy >=0.17.0 : 1.11.4 (OK) sympy >=0.7.3 : 1.12 (OK) ```
ingo-m commented 3 weeks ago

PS: I can get the Spyder variable explorer to work when pinning the versions of numpy, pandas, scipy, and matplotlib in the conda env to the exact same versions as the Spyder dependencies. But these versions are fairly old, and cause dependency conflicts if I'm trying to include any additional packages in my conda env.

ccordoba12 commented 3 weeks ago

Hey @ingo-m, this is basically a duplicate of issue #22784, so I'm going to close it in favor of that one.

You also found the cause of this problem:

PS: I can get the Spyder variable explorer to work when pinning the versions of numpy, pandas, scipy, and matplotlib in the conda env to the exact same versions as the Spyder dependencies.

This means your distro packages depend on Numpy 1 but you had Numpy 2 installed in your conda env. Since the two versions don't produce compatible objects, it's not possible to use the Variable Explorer to visualize arrays or dataframes with it.

ccordoba12 commented 3 weeks ago

Sorry, this was actually not a duplicate of #22784, but now you know the cause and why what you did worked.

We'll try to provide a better error message for this in a later release.

ingo-m commented 3 weeks ago

Ok thanks.

If there's nothing more that can be done about it at the moment I don't mind if you close the issue, I just thought it makes sense to document the issue here for others & future reference.

The root cause of my problem is that I can't get spyder to work in a conda env on Ubuntu 24 (which uses wayland). Installing spyder as a deb package is only a workaround, which in turn causes the problem with the variable explorer.

ccordoba12 commented 3 weeks ago

The root cause of my problem is that I can't get spyder to work in a conda env on Ubuntu 24 (which uses wayland).

Well, you can also install Xorg with apt and use a Xorg session instead. That way you'll be able to use conda instead of the distro package, which is always going to be outdated.