I am working on a project that is using the MCP23017. I am confused by your library and tutorial for this product. If I open the code in the Python IDLE, do the edits and save. That works. The code will only execute with terminal commands, however will not run from IDLE. IDLE complains that your syntax of tabs is messed up. Because of this, importing the library into my code is not working. Any tips?
Thanks,
Bill
MCP230xx code?
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: MCP230xx code?
you might have to replace the tabs with spaces, its something that IDLE might be sensitive to - we'll eventually readapt our python code to spaces instead of tabs but there's no ETA so for now please do it by hand.
-
- Posts: 466
- Joined: Thu Aug 30, 2012 1:34 am
Re: MCP230xx code?
the file doesn't look like they mix tabs and spaces at the beginnings of lines in any sort of irresponsible manner so you might try
then you can try out foooo on the python interpreter and if it works replace the mcp23007 library with foooo. don't have an mcp23007 handy or i'd try it myself.
Code: Select all
sed "s/\t/ /g" Adafruit_MCP230xx.py > foooo
- ohnoitsmrbill
- Posts: 33
- Joined: Mon Sep 17, 2012 7:50 pm
Re: MCP230xx code?
Tldr the file did have a few lines that were found using "Untabify Region". However, it looks like the code has to be run with Sudo as the GPIO appears to need root access. Is there any way around this?
-
- Posts: 466
- Joined: Thu Aug 30, 2012 1:34 am
Re: MCP230xx code?
sudo is probably the easiest way to run your code. the other possibility would be to change the ownership or permissions on the various device files. problem is i'm not sure when or where these are created. some of them only seem to exist while your script is running. some of them can be created if you are logged in as root, (but i can't log in as root on my pi), or if you use "sudo -i", (which will effectively log you in as root).OhNoItsMrBill wrote: However, it looks like the code has to be run with Sudo as the GPIO appears to need root access. Is there any way around this?
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/