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.
Import error for ADS1015 ADC
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Import error for ADS1015 ADC
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.
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.
-
- Posts: 3
- Joined: Wed Mar 19, 2014 1:39 pm
Re: Import error for ADS1015 ADC
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?
I installed the libraries using:
sudo apt-get install python-pip
sudo pip install Adafruit_Libraries
Is this correct?
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Import error for ADS1015 ADC
That's the information I needed.
When you install the modules that way, you need to write the 'import' line differently. Instead of:
You need:
When you install the modules that way, you need to write the 'import' line differently. Instead of:
Code: Select all
from Adafruit_ADS1x15 import ADS1x15
Code: Select all
from Adafruit.ADS1x15 import Adafruit_ADS1x15
- rmitchell
- Posts: 1
- Joined: Sun Mar 05, 2017 4:31 pm
Re: Import error for ADS1015 ADC
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
This, by default, only installs the library in Python2. If you are using Python3, you need the following installation: sudo python3 setup.py install
- mron
- Posts: 8
- Joined: Sat Jun 22, 2013 11:59 pm
Re: Import error for ADS1015 ADC
I'm having the same problem. I just upgraded from wheezy to jessie. A python script no longer works. Here's the trouble line:
here's the error:
I'm running python 2.79, rpi, latest jessie. Here's a list of locally installed python modules:
Code: Select all
from Adafruit.ADS1x15 import Adafruit_ADS1x15
Code: Select all
File "./TankHeight_Temp_Humdity_Sampler_test.py", line 8, in <module>
from Adafruit import Adafruit_ADS1x15
ImportError: No module named Adafruit
Code: Select all
['adafruit-ads1x15==1.0.2', 'adafruit-gpio==1.0.3', 'adafruit-pureio==0.2.1', 'spidev==3.2']
- mron
- Posts: 8
- Joined: Sat Jun 22, 2013 11:59 pm
Re: Import error for ADS1015 ADC
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?
- Farqhuit
- Posts: 37
- Joined: Sat Mar 17, 2018 6:04 pm
Re: Import error for ADS1015 ADC
Mitchell, thank you so much for this. Sorted my problem pronto. I was getting quite discouraged. Cheers mate!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
Please be positive and constructive with your questions and comments.