Comments (11)
Interesting, do you have an example of the code that throws the error? Just want to repro it since I haven't seen it myself.
The intention is just to pull in the GPIO module so you can say:
import Adafruit_GPIO
Or:
import Adafruit_GPIO as GPIO
And start using the GPIO functions, since they're so commonly used. For other modules like SPI, I2C, etc. they have to be specified like:
import Adafruit_GPIO.SPI as SPI
from adafruit_python_gpio.
OK, I think I found the reason (I have it just by running any import like import Adafruit_GPIO
).
I use the libraries with python3 which doesn't seem to like implicit relative imports!
Either from Adafruit_GPIO.GPIO import *
or from .GPIO import *
seems to work with both Python 2 & 3 :-)
from adafruit_python_gpio.
Oh interesting, yeah python3 compat is on my todo list so it's good to know this might be kind of sketchy behavior. I'm not really attached to the shortcut, and it's probably better for me to change it sooner rather than later. I'll keep this issue open so I can come back to it when I test the libraries for python3 compatibility and perhaps drop the import entirely.
from adafruit_python_gpio.
Hi Carlos,
I think there is a confusion of libraries.
Adafruit's code is wrapper for original RPi.GPIO library as well as
the Beaglebone's
one. The way to use it is slightly different. See
https://github.com/adafruit/Adafruit_Nokia_LCD for examples.
Thus the code for the RPi.GPIO (
http://sourceforge.net/projects/raspberry-gpio-python/ ) takes indeed this
form:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(9, GPIO.OUT)
while the one for the Adafruit_GPIO takes this one:
import Adafruit_GPIO as GPIO
gpio = GPIO.get_platform_gpio()
gpio.setup(9, GPIO.OUT)
Good luck!
François.
On 29 December 2014 at 23:43, Carlos Cesario [email protected]
wrote:
Hello,
I 'm testing this lib, but or my code is wrong or can be a bug :)import Adafruit_GPIO as GPIO
GPIO.setmode(GPIO.BCM)This code cause error
Traceback (most recent call last):
File "text.py", line 2, in
GPIO.setmode(GPIO.BCM)
AttributeError: 'module' object has no attribute 'setmode'Does someone have idea ?
Regards,
Carlos
—
Reply to this email directly or view it on GitHub
#7 (comment)
.
from adafruit_python_gpio.
Coming back to this one a bit late, but I just merged in #17 which should make the library work with Python 3. Let me know if you see any issues--thanks!
from adafruit_python_gpio.
I had this issue today on Python 2.7
I replaced from Adafruit_GPIO.GPIO import *
with from .GPIO import *
in the __init__.py
file and the other imports in GPIO.py
and I2C.py
accordingly. This has fixed it for me.
You have an idea to this?
from adafruit_python_gpio.
That's odd, just to check what platform are you using (Pi, PC, etc.) and what Python minor version too (like 2.7.9, etc)?
from adafruit_python_gpio.
I am using a Raspberry Pi 2 running Python 2.7.9 and Raspbian.
I did not install the module globally, I put it into the working folder and included it from there.
from adafruit_python_gpio.
Oh gotcha thanks for clarifying the usage. Let me raise a new issue to track switching over all the imports to proper python 2.7 & 3 relative ones. It's good for python 2 & 3--I just want to spend a little time to test out a few things and make sure it works for all the library's uses. Thanks!
New issue is here: #28
from adafruit_python_gpio.
I received the error "ImportError: No module named 'Adafruit_PureIO'" when I tried to run simpletest.py
for MCP9808 with python3 (python3 simpletest.py
). I then installed Adafruit_PureIO with python3:
git clone https://github.com/adafruit/Adafruit_Python_PureIO.git
cd Adafruit_Python_PureIO
sudo python3 setup.py install
And this solved the problem issue.
from adafruit_python_gpio.
i am using putty and remote desktop to connect to raspberry pi
when i run program with Adafruit_PCA9685 in putty command line that uses python 2.7 it runs the program but when when i use python 3.5.3 shell it gives import error
i did every thing this conversation says
but
SAME ERROR
"importerror no module named 'adafruit pca9685'"
from adafruit_python_gpio.
Related Issues (20)
- Could not determine platform on Jetson Nano HOT 1
- Does not work with Raspberry Pi 4 HOT 1
- Incorrect detection of Raspberry Pi version HOT 4
- Local variable 'gpio' shadows self.gpio HOT 1
- Platform.pi_version() regex fails HOT 1
- error accessing p8_7 and p8_8 on BBB HOT 3
- Expose polarity argument on BBIO_PWM_Adapter.start() HOT 1
- Adafruit_Python_GPIO not compatible with Python 3.6.1, only Python 2.7.9 HOT 2
- no module named 'Adafruit_GPIO' (even though I checked everything) HOT 1
- RE: Using Your Software and Changing It/Seth HOT 1
- self._mosi should be self._miso
- Support arm64 for platform version HOT 1
- error on windows10 X64 (ver1803)
- FTH232H.py has import ftdi1 as ftdi HOT 11
- Support for Jetson TX2 HOT 4
- Library needs support for Odroid-C2 (ubuntu) HOT 1
- Unable to read user registry using readRaw8 with Adafruit_GPIO.FT232H i2c connection HOT 3
- Single-byte data corruption from FT232H Hardware Limits HOT 7
- ez_setup.py has deprecated methods for installing setuptools
- NameError: name 'ensurepip' is not defined HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_python_gpio.