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

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to define Missing value on some certain conditions? FreddieTheCat 3 143 Jan-14-2019, 01:35 AM
Last Post: scidam
  help for Kaggle Titanic Set fill the missing Age by median age of Pclass and Sex Parthasarathi009 2 146 Nov-21-2018, 06:50 PM
Last Post: Parthasarathi009
  edit text files/ add lines if missing (regex) wardancer84 3 188 Nov-08-2018, 02:47 PM
Last Post: wardancer84
  go_to() missing 1 required positional argument: 'url' HMAeymo 1 452 Aug-15-2018, 08:38 PM
Last Post: micseydel
  lxml missing libxml2, libxslt cawtx 3 1,088 Jul-13-2018, 11:49 PM
Last Post: snippsat
  SyntaxError: Missing parentheses in call to 'print' sofret 3 1,086 Jun-15-2018, 03:23 PM
Last Post: buran
  Build applet utility missing MaxN 0 309 May-03-2018, 06:59 PM
Last Post: MaxN
  TypeError: exitfunc() missing 1 required positional argument: 'self' venkateshrathod 3 3,055 Apr-29-2018, 09:39 AM
Last Post: Larz60+
  The following modules appear to be missing ['_pybsddb'] py2exe 2 528 Apr-26-2018, 12:49 AM
Last Post: py2exe
  TypeError: get_formatted_name() missing 1 required positional argument: 'last_name' tjnichols 4 5,161 Mar-28-2018, 07:38 PM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)