Closed WaaromZoMoeilijk closed 5 years ago
Try with python3 instead of python
I have the same error, when I try python3
pi@tvPi:~/system_sensors/src $ python3 system_sensors.py
Traceback (most recent call last):
File "system_sensors.py", line 4, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
I have the same error, when I try
python3
pi@tvPi:~/system_sensors/src $ python3 system_sensors.py Traceback (most recent call last): File "system_sensors.py", line 4, in <module> import psutil ModuleNotFoundError: No module named 'psutil'
That's a different error. You didn't install the requirements. You need to follow the readme step by step. pip install -r requirements.txt
I did
pi@tvPi:~/system_sensors $ pip install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting paho-mqtt==1.4.0 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/25/63/db25e62979c2a716a74950c9ed658dce431b5cb01fde29eb6cba9489a904/paho-mqtt-1.4.0.tar.gz (88kB)
100% |████████████████████████████████| 92kB 1.4MB/s
Collecting psutil==5.6.3 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/1c/ca/5b8c1fe032a458c2c4bcbe509d1401dca9dda35c7fc46b36bb81c2834740/psutil-5.6.3.tar.gz (435kB)
100% |████████████████████████████████| 440kB 613kB/s
Collecting pytz==2019.2 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl (508kB)
100% |████████████████████████████████| 512kB 571kB/s
Building wheels for collected packages: paho-mqtt, psutil
Running setup.py bdist_wheel for paho-mqtt ... done
Stored in directory: /home/pi/.cache/pip/wheels/82/e5/de/d90d0f397648a1b58ffeea1b5742ac8c77f71fd43b550fa5a5
Running setup.py bdist_wheel for psutil ... done
Stored in directory: /home/pi/.cache/pip/wheels/90/7e/74/bb640d77775e6b6a78bcc3120f9fea4d2a28b2706de1cff37d
Successfully built paho-mqtt psutil
Installing collected packages: paho-mqtt, psutil, pytz
Successfully installed paho-mqtt-1.4.0 psutil-5.6.3 pytz-2019.2
pi@tvPi:~/system_sensors $ python system_sensors.py
python: can't open file 'system_sensors.py': [Errno 2] No such file or directory
pi@tvPi:~/system_sensors $ ls
images LICENSE README.md requirements.txt src
pi@tvPi:~/system_sensors $ cd src
pi@tvPi:~/system_sensors/src $ ls
system_sensors.py
pi@tvPi:~/system_sensors/src $ python system_sensors.py
File "system_sensors.py", line 49
def utc_from_timestamp(timestamp: float) -> dt.datetime:
^
SyntaxError: invalid syntax
pi@tvPi:~/system_sensors/src $ python3 system_sensors.py
Traceback (most recent call last):
File "system_sensors.py", line 4, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
Now I've tried with sudo
pi@tvPi:~/system_sensors $ sudo pip install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting paho-mqtt==1.4.0 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/25/63/db25e62979c2a716a74950c9ed658dce431b5cb01fde29eb6cba9489a904/paho-mqtt-1.4.0.tar.gz (88kB)
100% |████████████████████████████████| 92kB 1.5MB/s
Collecting psutil==5.6.3 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/1c/ca/5b8c1fe032a458c2c4bcbe509d1401dca9dda35c7fc46b36bb81c2834740/psutil-5.6.3.tar.gz (435kB)
100% |████████████████████████████████| 440kB 616kB/s
Collecting pytz==2019.2 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl (508kB)
100% |████████████████████████████████| 512kB 572kB/s
Building wheels for collected packages: paho-mqtt, psutil
Running setup.py bdist_wheel for paho-mqtt ... done
Stored in directory: /root/.cache/pip/wheels/82/e5/de/d90d0f397648a1b58ffeea1b5742ac8c77f71fd43b550fa5a5
Running setup.py bdist_wheel for psutil ... done
Stored in directory: /root/.cache/pip/wheels/90/7e/74/bb640d77775e6b6a78bcc3120f9fea4d2a28b2706de1cff37d
Successfully built paho-mqtt psutil
Installing collected packages: paho-mqtt, psutil, pytz
Successfully installed paho-mqtt-1.4.0 psutil-5.6.3 pytz-2019.2
pi@tvPi:~/system_sensors $ ls
images LICENSE README.md requirements.txt src
pi@tvPi:~/system_sensors $ cd src
pi@tvPi:~/system_sensors/src $ python system_sensors.py
File "system_sensors.py", line 49
def utc_from_timestamp(timestamp: float) -> dt.datetime:
^
SyntaxError: invalid syntax
pi@tvPi:~/system_sensors/src $ python3 system_sensors.py
Traceback (most recent call last):
File "system_sensors.py", line 4, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
You have 2 different pip. One for python2 and one for python3. Try with pip3 install -r requirements.txt or if that doesn't work: python3 -m pip install -r requirements.txt
That's a different error. You didn't install the requirements. You need to follow the readme step by step.
Sorry if I wasn't clear, I have the same error on python
And a different one on python3
I fixed it by
pi@tvPi:~/system_sensors/src $ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
rpi.gpio-common
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
dh-python libpython3-dev libpython3.7-dev python3-asn1crypto python3-cffi-backend python3-crypto python3-cryptography
python3-dbus python3-dev python3-distutils python3-entrypoints python3-gi python3-keyring python3-keyrings.alt
python3-lib2to3 python3-secretstorage python3-setuptools python3-wheel python3-xdg python3.7-dev
Suggested packages:
python-crypto-doc python-cryptography-doc python3-cryptography-vectors python-dbus-doc python3-dbus-dbg gnome-keyring
libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc
The following NEW packages will be installed:
dh-python libpython3-dev libpython3.7-dev python3-asn1crypto python3-cffi-backend python3-crypto python3-cryptography
python3-dbus python3-dev python3-distutils python3-entrypoints python3-gi python3-keyring python3-keyrings.alt
python3-lib2to3 python3-pip python3-secretstorage python3-setuptools python3-wheel python3-xdg python3.7-dev
0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 49.5 MB of archives.
After this operation, 80.5 MB of additional disk space will be used.
Setting up python3-entrypoints (0.3-1) ...
Setting up python3-dbus (1.2.8-3) ...
Setting up libpython3.7-dev:armhf (3.7.3-2) ...
Setting up python3-xdg (0.25-5) ...
Setting up python3-wheel (0.32.3-2) ...
Setting up python3.7-dev (3.7.3-2) ...
Setting up python3-gi (3.30.4-1) ...
Setting up python3-crypto (2.6.1-9+b1) ...
Setting up python3-lib2to3 (3.7.3-1) ...
Setting up python3-asn1crypto (0.24.0-1) ...
Setting up python3-cffi-backend (1.12.2-1) ...
Setting up python3-distutils (3.7.3-1) ...
Setting up dh-python (3.20190308) ...
Setting up libpython3-dev:armhf (3.7.3-1) ...
Setting up python3-setuptools (40.8.0-1) ...
Setting up python3-cryptography (2.6.1-3) ...
Setting up python3-dev (3.7.3-1) ...
Setting up python3-pip (18.1-5+rpt1) ...
Setting up python3-keyrings.alt (3.1.1-1) ...
Setting up python3-secretstorage (2.3.1-2) ...
Setting up python3-keyring (17.1.1-1) ...
Processing triggers for man-db (2.8.5-2) ...
pi@tvPi:~/system_sensors/src $ sudo pip3 install -r requirements.txt
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
pi@tvPi:~/system_sensors/src $ cd ..
pi@tvPi:~/system_sensors $ pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting paho-mqtt==1.4.0 (from -r requirements.txt (line 1))
Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.4.0-py3-none-any.whl (48kB)
100% |████████████████████████████████| 51kB 997kB/s
Collecting psutil==5.6.3 (from -r requirements.txt (line 2))
Downloading https://www.piwheels.org/simple/psutil/psutil-5.6.3-cp37-cp37m-linux_armv7l.whl (279kB)
100% |████████████████████████████████| 286kB 1.0MB/s
Collecting pytz==2019.2 (from -r requirements.txt (line 3))
Using cached https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl
Installing collected packages: paho-mqtt, psutil, pytz
Successfully installed paho-mqtt-1.4.0 psutil-5.6.3 pytz-2019.2
pi@tvPi:~/system_sensors $ cd src
pi@tvPi:~/system_sensors/src $ python3 system_sensors.py
Thanks both, sudo apt install python3-pip
did the trick with pip3 install
Hey, thanks for this great project!
Did everything according the readme, rasbian 4.19.57-v7+ armv7l. Please advise.