Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 12:24 am

Hello,

I've ran into a small problem in that I can't seem to import GPIO on my regular computer, it give me a message of some sort that it can only be ran on a raspberry pi. Of course I'd like to write the code on my regular PC and the send it over to the RP, so how is this normally done?

thanks,
Bruce

TheWalkingCactus
Posts: 14
Joined: Fri Mar 29, 2013 7:53 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 2:44 am

Firstly, why do you want to program it on your main computer? And how would you simply 'send it over?' I think it's much easier to just program right on the Pi, to greatly simplify debuging.

How I do it (not sure if this is 'normal' so to speak) is to log in as Root and then just write it in Idle. If you've never used the Root user before, see here: http://elinux.org/R-Pi_Troubleshooting# ... t_password

Then
- Either SSH & VNC into the Pi, or use a screen and keyboard.
- Log in as Root and enter the password
- Click the 'menu' button on the bottom left
- Select `Run`
- Type

Code: Select all

sudo Idle
- Program as usual


The only reason you can't just do it in the normal user is that the GPIO stuff needs root access, but doing what I describes work perfectly.
Last edited by TheWalkingCactus on Sun Oct 20, 2013 2:57 pm, edited 1 time in total.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 5:51 am

You can write the code with a code editor anywhere you wish. However, only the Raspberry Pi has the GPIO hardware to match the RPi.GPIO library you are importing into your Python code. Therefore you need to transfer your code from where you wrote it to where you need it - you could copy it to USB drive, FTP it across, post it somewhere on the web and then copy it back (dropbox).

Lots of options
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

WebPi
Posts: 262
Joined: Wed Apr 10, 2013 6:47 pm
Location: Birmingham, UK
Contact: Website

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 6:07 am

If you share your Pi's folders on your network using samba, you can open files on your Pi on your PC.
raspberrywebserver.com - Raspberry Pi tutorials
LinuxWebServers.net - Linux Web Server tutorials and examples
pyplate.com - Python web publishing tool

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 9:31 am

Hi all,

Thanks for the ideas. Basically what I have is a RP sitting without a keyboard or monitor, so right now I use putty to SSH into the machine to install/run stuff. For sending over the files I use filezilla with SSH, very easy. So let me think about it some more. I'll post back with whatever I endup doing.

Thanks,
Bruce

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 3:42 pm

ok I'm really happy now, I ended up using "xrdp" to remote into the desktop, here is the video that helped me
http://www.youtube.com/watch?v=Y5SHRazACBE

It's really with linux becuase I can just put that instance in another workspace and quickly switch back and fourth. And I still have the filezilla for sending files over.

Bruce

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 6:37 pm

Hi again,

another issue I'm running into...

I'm starting idle in the terminal like "sudo idle".

idle starts as expected but when try to run my program is says that it cant access the /dev/mem/, try running as root!
I'm totally confused because I can find a lot of information everywhere telling to start it up with sudo which I'm doing. I've even tried to feed it into the idle terminal or whatever it's call and still get the same result.

any idea?

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 6:57 pm

I must be on the wrong path, because I went to the file "mem" did chmod 777, which set everything to read/write and it's still won't work!

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 8:30 pm

small update. I have found that I can run it from terminal by doing "sudo python MYPROGRAM". Still it's not working from idle.

Ecurb
Posts: 25
Joined: Sun Oct 06, 2013 6:31 pm

Re: python-rpi.gpio off raspberry pi

Sun Oct 20, 2013 8:46 pm

final update. After working with it this way I think it's fine, I just work on the program in IDLE and then run it from the terminal. Thanks again folks.

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: python-rpi.gpio off raspberry pi

Mon Oct 21, 2013 11:34 am

You could also try

Code: Select all

sudo idle
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “General programming discussion”