0

Import error for ADS1015 ADC
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Import error for ADS1015 ADC

by adrianthegasman on Wed Mar 19, 2014 1:43 pm

I have recently purchased an ADS1015 ADC board.

I believe I have installed the appropriate libraries but the following python code fails: from Adafruit_ADS1x15 import ADS1x15

...with the error "No module named Adafruit_ADS1x15"

All thoughts welcome.
adrianthegasman
 
Posts: 3
Joined: Wed Mar 19, 2014 1:39 pm

Re: Import error for ADS1015 ADC

by adafruit_support_mike on Wed Mar 19, 2014 5:02 pm

How did you install the libraries?

Python's 'import' rules are slightly different for system modules and local modules, and there doesn't seem to be any clean way of making files that will work in either location. The RasPi Python code was written for standalone operation as a github repository, but there are also package-manager installations that put the files in the standard module tree.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 61796
Joined: Thu Feb 11, 2010 2:51 pm

Re: Import error for ADS1015 ADC

by adrianthegasman on Thu Mar 20, 2014 5:42 am

Apologies, I’m a newby to the Pi and I didn’t quite understand all of your response – I’ll get there eventually :-)

I installed the libraries using:

sudo apt-get install python-pip
sudo pip install Adafruit_Libraries

Is this correct?
adrianthegasman
 
Posts: 3
Joined: Wed Mar 19, 2014 1:39 pm

Re: Import error for ADS1015 ADC

by adafruit_support_mike on Fri Mar 21, 2014 6:07 pm

That's the information I needed.

When you install the modules that way, you need to write the 'import' line differently. Instead of:

Code: Select all | TOGGLE FULL SIZE
 from Adafruit_ADS1x15 import ADS1x15

You need:

Code: Select all | TOGGLE FULL SIZE
 from Adafruit.ADS1x15 import Adafruit_ADS1x15
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 61796
Joined: Thu Feb 11, 2010 2:51 pm

Re: Import error for ADS1015 ADC

by rmitchell on Sun Mar 05, 2017 4:38 pm

I had this problem and I finally realised that the issue was that the Raspberry Pi had both Python2 and Python3 installed. AdaFruit instructions tell you to install the library using: sudo python setup.py install

This, by default, only installs the library in Python2. If you are using Python3, you need the following installation: sudo python3 setup.py install

rmitchell
 
Posts: 1
Joined: Sun Mar 05, 2017 4:31 pm

Re: Import error for ADS1015 ADC

by mron on Wed May 10, 2017 7:24 pm

I'm having the same problem. I just upgraded from wheezy to jessie. A python script no longer works. Here's the trouble line:
Code: Select all | TOGGLE FULL SIZE
from Adafruit.ADS1x15 import Adafruit_ADS1x15

here's the error:
Code: Select all | TOGGLE FULL SIZE
File "./TankHeight_Temp_Humdity_Sampler_test.py", line 8, in <module>
    from Adafruit import Adafruit_ADS1x15
ImportError: No module named Adafruit


I'm running python 2.79, rpi, latest jessie. Here's a list of locally installed python modules:
Code: Select all | TOGGLE FULL SIZE
['adafruit-ads1x15==1.0.2', 'adafruit-gpio==1.0.3', 'adafruit-pureio==0.2.1', 'spidev==3.2']

mron
 
Posts: 2
Joined: Sat Jun 22, 2013 11:59 pm

Re: Import error for ADS1015 ADC

by mron on Thu May 11, 2017 1:25 am

I looked at the example code and got it working. My old library had a function "adc.readADCSingleEnded(0, gain, sps)". The new library has "adc.read_adc( 0, gain, sps )". Is it a single-ended read? I used a sample rate of 8 on the old module. The new one needs 128. Are the old and the new 128 the same? I had a gain of 4096 in the old module, I think this corresponds to "1" in the new. Are these the correct setting? Is it single-ended of differential?

mron
 
Posts: 2
Joined: Sat Jun 22, 2013 11:59 pm

Re: Import error for ADS1015 ADC

by Farqhuit on Sat Mar 17, 2018 6:36 pm

rmitchell wrote:I had this problem and I finally realised that the issue was that the Raspberry Pi had both Python2 and Python3 installed. AdaFruit instructions tell you to install the library using: sudo python setup.py install

This, by default, only installs the library in Python2. If you are using Python3, you need the following installation: sudo python3 setup.py install


Mitchell, thank you so much for this. Sorted my problem pronto. I was getting quite discouraged. Cheers mate!

Farqhuit
 
Posts: 37
Joined: Sat Mar 17, 2018 6:04 pm

Please be positive and constructive with your questions and comments.