Bottom Page

Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Missing something here
Hi all,
Never used Python before so I'm using some scripts someone else has created for an automated watering system running on a RaspberryPi (Raspbian Stretch - a Debian fork IIRC). This system uses Flask and psutil, and it's in this last that the problem seems to lie. I installed this using the command
:~ $ python3.5 -m pip install psutil

pip is at version 9.0.1

which returned, after a few seconds the message "Successfully installed psutil-5.4.8". All well and good! So now to run the code which returns

:~ $ sudo python3
Traceback (most recent call last):
File "", line 2, in <module>
import psutil
ImportError: No module named 'psutil'


pi@water1:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil

So the problem appears to be that the import command from within the script can't find the module.
The location of psutil is at /home/pi/.local/lib/python3.5/site-packages so it's definitely there. Am I missing something in a config file or is there another reason for this?


Solved my problem myself by copying the psutil folder in to the directory where the scripts were. However, I'd still like to know why it couldn't find the original install module.

You like this post
I'd guess it's because you installed psutil lib locally just for user 'pi' and you are trying to run your script as root which is missing the psutil library. Either run your script as 'pi' user:
or install psutil as root:
sudo pip install psutil
You like this post
The problem is that you can do a systemwide install with sudo python3 -m pip install psutil and you did a user install wich is only usable under your login. You need to uninstall and reinstall systemwide.
You like this post

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)