Giter VIP home page Giter VIP logo

Comments (11)

tdicola avatar tdicola commented on June 2, 2024

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.

guillier avatar guillier commented on June 2, 2024

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.

tdicola avatar tdicola commented on June 2, 2024

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.

guillier avatar guillier commented on June 2, 2024

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.

tdicola avatar tdicola commented on June 2, 2024

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.

PaulDebus avatar PaulDebus commented on June 2, 2024

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.

tdicola avatar tdicola commented on June 2, 2024

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.

PaulDebus avatar PaulDebus commented on June 2, 2024

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.

tdicola avatar tdicola commented on June 2, 2024

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.

eimose avatar eimose commented on June 2, 2024

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.

orkutsoft avatar orkutsoft commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.