Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Import error : 'No module named Adafruit_IO
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Import error : 'No module named Adafruit_IO

by PJvG on Sun Jun 07, 2020 9:43 am

Hi,

I have trouble to connect with adafruit_io

I'm working with :
- Raspberry Pi 3
- Python 3.7.3
- I have installed : pip3 install adafruit-io

I get a 'Import error : 'No module named Adafruit_IO' error during running the following test-example:



from Adafruit_IO import Client, RequestError, Feed
ADAFRUIT_IO_KEY = 'my key'
ADAFRUIT_IO_USERNAME = 'my username'
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

try:
test_feed = aio.feeds('test-feed')
except RequestError: # Doesn't exist, create a new feed
test = Feed(name='test-feed')
test_feed = aio.create_feed(test)

aio.send_data(test_feed.key, 42)




Does anybody knows if I make a mistake ?
It looks like the module adafruit_io is not installed

PJvG
 
Posts: 5
Joined: Sun Jun 07, 2020 9:16 am

Re: Import error : 'No module named Adafruit_IO

by brubell on Mon Jun 08, 2020 11:37 am

Hi PJvG,

I just ran pip3 install adafruit-io and was unable to replicate this issue.

When you installed Adafruit IO, did it say "Successfully installed adafruit-io-2.4.0"? You could try uninstalling (pip3 uninstall adafruit-io) and reinstalling Adafruit IO again.

Code: Select all | TOGGLE FULL SIZE
 ~  pip3 install adafruit-io
Collecting adafruit-io
  Downloading adafruit-io-2.4.0.tar.gz (50 kB)
     |████████████████████████████████| 50 kB 1.8 MB/s
Requirement already satisfied: requests in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (from adafruit-io) (2.23.0)
Collecting paho-mqtt
  Downloading paho-mqtt-1.5.0.tar.gz (99 kB)
     |████████████████████████████████| 99 kB 3.4 MB/s
Requirement already satisfied: chardet<4,>=3.0.2 in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (from requests->adafruit-io) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (from requests->adafruit-io) (1.25.9)
Requirement already satisfied: idna<3,>=2.5 in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (from requests->adafruit-io) (2.9)
Requirement already satisfied: certifi>=2017.4.17 in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (from requests->adafruit-io) (2020.4.5.1)
Using legacy setup.py install for adafruit-io, since package 'wheel' is not installed.
Using legacy setup.py install for paho-mqtt, since package 'wheel' is not installed.
Installing collected packages: paho-mqtt, adafruit-io
    Running setup.py install for paho-mqtt ... done
    Running setup.py install for adafruit-io ... done
Successfully installed adafruit-io-2.4.0 paho-mqtt-1.5.0
 ~  python3
Python 3.7.2 (default, May 19 2020, 12:08:53)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Adafruit_IO import Client, RequestError, Feed

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Thu Jun 11, 2020 1:29 am

I'm having the same issue, I have uninstalled and sucsessfully reinstalled the module. But I still get the same error.
the program will run from Thonny, but I am unable to get it to run from terminal, nor via SSH Putty

"Successfully installed adafruit-io-2.4.0
pi@raspberrypi:~ $ sudo python temperature.py
Traceback (most recent call last):
File "temperature.py", line 34, in <module>
from Adafruit_IO import Client, Feed
ImportError: No module named Adafruit_IO"


I hope to run this in the roof to monitor hotwater, so it will be headerless

Raspberry pi 3 running Raspberry pi OS

Thanks

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Re: Import error : 'No module named Adafruit_IO

by PJvG on Sat Jun 13, 2020 11:39 am

Hi brubell

I have uninstalled en installed adafruit-io with the message 'Successfully installed adafruit-io-2.4.0'

When I'm running via VNC the terminal of my raspberry there is the same error : no module adafruit_io.

It works well when I start the program with Thonny , no error messages and the feed value is visible inside my adafruit account.
For me this is a good way of working but strange with the error starting from the terminal

greetings and thanks for your help ,
PJ

PJvG
 
Posts: 5
Joined: Sun Jun 07, 2020 9:16 am

Re: Import error : 'No module named Adafruit_IO

by brubell on Mon Jun 15, 2020 11:12 am

From Thonny, could you run the following code:

Code: Select all | TOGGLE FULL SIZE
import sys
print("Python version")
print (sys.version)
print("Version info.")
print (sys.version_info)


Then, could you run python3 from the command terminal and enter the commands above into the interpreter?

I'm curious if there's a python version mis-match

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Mon Jun 15, 2020 9:02 pm

Running from Thonny I get:

Python version
3.7.3(default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
version info
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)

However running from SSH Putty I get:

Python version
2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0]
version info
sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Re: Import error : 'No module named Adafruit_IO

by brubell on Wed Jun 17, 2020 11:01 am

Ok! It seems you have two different installations of Python on your Pi, and Adafruit IO Python is installed in 3.7.3 (for Thonny).

Could you try using Python3 to run your script by entering the following into your terminal:
Code: Select all | TOGGLE FULL SIZE
sudo python3 temperature.py

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Wed Jun 17, 2020 5:44 pm

Thanks
from SSH terminal

pi@raspberrypi:~ $ sudo python3 temperature.py
Traceback (most recent call last):
File "temperature.py", line 34, in <module>
from Adafruit_IO import Client, Feed
ModuleNotFoundError: No module named 'Adafruit_IO'

I also ran the version script both ad python and python 3. both in SSH terminal (this was after running an update and upgrade)

pi@raspberrypi:~ $ sudo python version.py
Python version
2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0]
version info
sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)

pi@raspberrypi:~ $ sudo python3 version.py
Python version
3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
version info
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
pi@raspberrypi:~ $

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Wed Jun 17, 2020 6:10 pm

I have now used remove and auto-remove to remove python with this result:

pi@raspberrypi:~ $ sudo python version.py
sudo: python: command not found

pi@raspberrypi:~ $ sudo python3 version.py
Python version
3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
version info
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)

pi@raspberrypi:~ $ sudo python3 temperature.py
Traceback (most recent call last):
File "temperature.py", line 34, in <module>
from Adafruit_IO import Client, Feed
ModuleNotFoundError: No module named 'Adafruit_IO'

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Re: Import error : 'No module named Adafruit_IO

by brubell on Fri Jun 19, 2020 10:08 am

Could you please enter the following into your terminal:
Code: Select all | TOGGLE FULL SIZE
pip3 freeze


and paste the output below?

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Fri Jun 19, 2020 5:51 pm

adafruit-io==2.4.0
appdirs==1.4.3
asn1crypto==0.24.0
astroid==2.1.0
asttokens==1.1.13
automationhat==0.2.0
beautifulsoup4==4.7.1
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2018.8.24
chardet==3.0.4
Click==7.0
colorama==0.3.7
colorzero==1.1
cookies==2.2.1
cryptography==2.6.1
cycler==0.10.0
decorator==4.3.0
docutils==0.14
drumhat==0.1.0
entrypoints==0.3
envirophat==1.0.0
ExplorerHAT==0.4.2
Flask==1.0.2
fourletterphat==0.1.0
gpiozero==1.5.1
guizero==0.6.0
html5lib==1.0.1
idna==2.6
ipykernel==4.9.0
ipython==5.8.0
ipython-genutils==0.2.0
isort==4.3.4
itsdangerous==0.24
jedi==0.13.2
Jinja2==2.10
jupyter-client==5.2.3
jupyter-core==4.4.0
keyring==17.1.1
keyrings.alt==3.1.1
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
logilab-common==1.4.2
lxml==4.3.2
MarkupSafe==1.1.0
matplotlib==3.0.2
mccabe==0.6.1
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.3
mypy==0.670
mypy-extensions==0.4.1
nudatus==0.0.4
numpy==1.16.2
oauthlib==2.1.0
olefile==0.46
paho-mqtt==1.5.0
pantilthat==0.0.7
parso==0.3.1
pexpect==4.6.0
pgzero==1.2
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
pickleshare==0.7.5
picraft==1.0
piglow==1.2.5
pigpio==1.44
Pillow==5.4.1
prompt-toolkit==1.0.15
psutil==5.5.1
pycairo==1.16.2
pycodestyle==2.4.0
pycrypto==2.6.1
pyflakes==2.0.0
pygame==1.9.4.post1
Pygments==2.3.1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pylint==2.2.2
pyOpenSSL==19.0.0
pyparsing==2.2.0
pyserial==3.4
python-apt==1.8.4.1
python-dateutil==2.7.3
pyxdg==0.25
pyzmq==17.1.2
qtconsole==4.3.1
rainbowhat==0.1.0
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
roman==2.0.0
RPi.GPIO==0.7.0
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
semver==2.0.1
Send2Trash==1.5.0
sense-emu==1.1
simplegeneric==0.8.1
simplejson==3.16.0
six==1.12.0
skywriter==0.0.7
sn3218==1.2.7
soupsieve==1.8
spidev==3.4
ssh-import-id==5.7
thonny==3.2.6
tornado==5.1.1
touchphat==0.0.1
traitlets==4.3.2
twython==3.7.0
typed-ast==1.3.1
uflash==1.2.4
unicornhathd==0.0.4
urllib3==1.24.1
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.14.1
wrapt==1.10.11
pi@raspberrypi:~ $

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Re: Import error : 'No module named Adafruit_IO

by PJvG on Sat Jun 20, 2020 9:50 am

I run also the codes :

CODE:
import sys
print("Python version")
print (sys.version)
print("Version info.")
print (sys.version_info)

RUNNING FROM TERMINAL:
Python version
2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0]
Version info.
sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)

RUNNING FROM THONNY:
Python version
3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
Version info.
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)


CODE:
python --version

RUNNING FROM TERMINAL:
Python 3.7.3

CODE:
pip3 freeze

RUNNING FROM TERMINAL:

adafruit-io==2.4.0
asn1crypto==0.24.0
astroid==2.1.0
asttokens==1.1.13
automationhat==0.2.0
beautifulsoup4==4.7.1
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2018.8.24
cffi==1.14.0
chardet==3.0.4
Click==7.0
colorama==0.3.7
colorzero==1.1
cookies==2.2.1
cryptography==2.6.1
decorator==4.3.0
Dexter-AutoDetection-and-I2C-Mutex==0.0.0
docutils==0.14
drumhat==0.1.0
entrypoints==0.3
envirophat==1.0.0
ExplorerHAT==0.4.2
Flask==1.0.2
fourletterphat==0.1.0
gpiozero==1.5.1
grovepi==1.4.1
html5lib==1.0.1
idna==2.6
isort==4.3.4
itsdangerous==0.24
jedi==0.13.2
Jinja2==2.10
keyring==17.1.1
keyrings.alt==3.1.1
lazy-object-proxy==1.3.1
logilab-common==1.4.2
lxml==4.3.2
MarkupSafe==1.1.0
mccabe==0.6.1
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.3
mypy==0.670
mypy-extensions==0.4.1
numpy==1.16.2
oauthlib==2.1.0
olefile==0.46
paho-mqtt==1.5.0
pantilthat==0.0.7
parso==0.3.1
pgzero==1.2
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
piglow==1.2.5
pigpio==1.44
Pillow==5.4.1
psutil==5.5.1
pycparser==2.20
pycrypto==2.6.1
pygame==1.9.4.post1
Pygments==2.3.1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pylint==2.2.2
pyOpenSSL==19.0.0
pyserial==3.4
python-apt==1.8.4.1
python-espeak==0.5
python-periphery==2.1.0
pyxdg==0.25
rainbowhat==0.1.0
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
roman==2.0.0
RPi.GPIO==0.7.0
RTIMULib==7.2.1
scipy==1.1.0
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
Send2Trash==1.5.0
sense-hat==2.2.0
simplejson==3.16.0
six==1.12.0
skywriter==0.0.7
smbus-cffi==0.5.1
sn3218==1.2.7
soupsieve==1.8
spidev==3.4
ssh-import-id==5.7
thonny==3.2.6
touchphat==0.0.1
twython==3.7.0
typed-ast==1.3.1
unicornhathd==0.0.4
urllib3==1.24.1
webencodings==0.5.1
Werkzeug==0.14.1
wiringpi==2.60.0
wrapt==1.10.11

with greetings John

PJvG
 
Posts: 5
Joined: Sun Jun 07, 2020 9:16 am

Re: Import error : 'No module named Adafruit_IO

by brubell on Mon Jun 22, 2020 9:47 am

CODE:
python --version

RUNNING FROM TERMINAL:
Python 3.7.3

CODE:
pip3 freeze

RUNNING FROM TERMINAL:

adafruit-io==2.4.0


It seems installed for your Python3 installation..

Could you launch Python3 with:
python3

Then type:
import Adafruit_IO

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Import error : 'No module named Adafruit_IO

by PJvG on Mon Jun 22, 2020 2:50 pm

This is the result :

python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Adafruit_IO
>>>

PJvG
 
Posts: 5
Joined: Sun Jun 07, 2020 9:16 am

Re: Import error : 'No module named Adafruit_IO

by AQman70 on Mon Jun 22, 2020 3:44 pm

same result here too

AQman70
 
Posts: 7
Joined: Thu Jun 11, 2020 1:12 am

Please be positive and constructive with your questions and comments.