Skip to content
Advertisement

pipx-installed Spyder doesn’t recognize Poetry-installed pandas only when trying to view DataFrame in Variable Explorer

I’m using Python 3.8.5. My OS is Kubuntu 18.04.

I installed Spyder and Poetry via pipx:

pipx install spyder --include-deps
pipx install poetry

Within my project folder, I installed pandas and spyder-kernels as dependencies:

poetry add pandas
poetry add --dev spyder-kernels

I can open Spyder just fine:

spyder3

In Spyder -> Preferences -> Python interpreter, I added the path to the Python interpreter for the project’s Poetry environment. I can import pandas in Spyder, like normal.

However, when I create a DataFrame (by reading an Excel file) in Spyder and try to double-click this DataFrame in the Variable Explorer, I get the following error message:

enter image description here

For those internet searching, it reads, “Spyder is unable to show the dataframe … because pandas was not installed alongside Spyder.”

In Spyder > Help > Dependencies, I confirm that pandas is listed as not installed:

# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.18.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  6.0.6 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.7.1 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.35.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  1.0.1 (OK)
qtconsole >=4.6.0              :  4.7.7 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.2 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  None (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  None (OK)
sympy >=0.7.3                  :  None (OK)

How can I get pandas installed in a place where my pipx-installed Spyder will recognize it? Apparently, it doesn’t recognize the Poetry-installed pandas.

I tried installing pandas with pipx:

pipx install pandas --include-deps

Didn’t work.

I tried running Spyder in a Poetry shell within the project folder:

poetry shell
spyder3

Didn’t work.

Advertisement

Answer

The problem seems to be that you installed spyder or its kernels on --dev and pandas as a general dependency.

As a test I created a new poetry environment and ran this:

poetry add pandas
poetry add spyder

And then ran spyder with poetry run spyder and worked like a charm, spyder recognizes pandas without any issues.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement