1

I am trying to detect keystroke on my Raspberry Pi 4. To do that I am running the code as,

sudo python3 example.py

But I get error, "No module named Pandas" (The code uses Pandas). But When I am running the code using Thonny, I get no error. And also I have pandas installed (confirmed using "pip list"). So, apparently If I run the code as root I get "no modules named pandas". If I run the code as,

python3 example.py

then no problem with pandas, but python keyboard module throws an error because of root access required. I have checked,

which python
>>>/usr/bin/python
sudo which python
>>>/usr/bin/python

Then I compared between

pip3 list
sudo pip3 list

Surprisingly I found that pip3 list gives me pandas(1.4.1). But no pandas were found in sudo pip3 list!!! Now what i did was,

sudo pip3 install pandas

Now the error has changed to, "numpy.ndarray size changed, may indicate binary incompatibility. Expected 48 from C header, got 40 from PyObject". But occurring only when running code as sudo.

FarhanAvro
  • 11
  • 2
  • Try reinstalling numpy. sudo pip3 install --upgrade numpy. This is based on: https://stackoverflow.com/a/66138833/2612429 – S2L Mar 16 '22 at 05:41

1 Answers1

0

My intuition tells me that the packages installed for the superuser might be different than the packages installed for the base user -- this could happen if pandas was installed via pip3 install --user pandas. Alternatively, the user and sudo might be using different versions of python.

To start debugging, I'd compare the output of sudo which python and which python as well as sudo pip3 list and look for any differences in environment.

awy
  • 43
  • 6
  • Thank you for you response. Based on your suggestions, I have updated the question. Will you kindly give a look. Thank you. – FarhanAvro Mar 16 '22 at 02:50