How can I transfer my Python files from PC to RPi?

7 posts
by kcranley » Fri Jul 06, 2012 2:01 pm
Forgive me if I am using the wrong part of the Forum, but I am a novice and have been busily typing in some Python programs to my PC (with Oracle VM Virtual Box, LXDE & Geany) before I got delivery of the Pi. Now that I have the little gem, I would like to easily transfer those Python files to the Pi. This would presumably be easiest done by accessing the SD card on the PC, so what commands etc would I need to type in? Please go gently as I need to be told PRECISELY what to do !! Thanks in advance. KC.
Posts: 16
Joined: Fri Jan 20, 2012 10:33 am
by stevep » Fri Jul 06, 2012 3:40 pm
I did this, but I use a Mac. First I had to transfer the Python files from within the VirtualBox environment onto the Mac desktop (or any other convenient publicly shared location that suits you). Then I used Samba to transfer the files from the Mac to the Pi. I did this in the LXDE desktop gui, by opening the file manager window and typing smb://192.168.1.x/<your public folder> in the address bar. You will need to substitute your own ip address for the 192.168.1.x I have written, and type the real name of your publicly shared folder.
There is a guide for getting Samba running on the Pi here (I have had trouble getting it to work using the Wheezy distribution, but it should work with Debian Squeeze).
Alternatively you could put them on a usb stick, and then learn how to mount the stick on the Pi - there are probably a few threads on here that to help you with the correct command and syntax to type.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by toxibunny » Fri Jul 06, 2012 3:53 pm
email them to yourself

access them on pi

job done.
note: I may or may not know what I'm talking about...
Posts: 1383
Joined: Thu Aug 18, 2011 9:21 pm
by bredman » Fri Jul 06, 2012 4:07 pm
If your virtual machine has internet access, you could copy the files to a network drive such as Dropbox or Sky Drive.
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm
by nadir » Fri Jul 06, 2012 4:26 pm
You can use filezilla to move files from Windows to Linux on the LAN easily (it works with ssh too, make sure it is started on the raspberry, say with "sudo /etc/init.d/ssh start", use port 22 in filezilla ).
To transfer them from Virtualbox to Windows host you will need to install and start filezilla-server on the Windows machine.

To copy them from VirtualBox to Windows and then from Windows to the raspberry seems a bit awkward.

I would use rsync.
Make sure
rsync is installed in VirtualBox and on the raspberry.
ssh server is running on the raspberry
VirtualBox -> settings -> network -> Adapter is set to "bridged adapter"
and run
Code: Select all
rsync -ruv ~/Programming/Python username@raspbery-IP:Programming

~ is your home directory
-r means recursive
u means copy only files which have changed (updated)
v means verbose
the colon : is the home directory at remote, hence use@remote:Programming is /home/you/Programming at the remote device (pc, laptop, raspberry, etc)
If you add a / behind the folder being rsynced, you won't copy the directory, but all subdirectories.
Not very clear? I agree. In short there is a difference between:
rsync -ruv ~/Programming user@remote:
rsync -ruv ~/Programming/ user@remote:
An easy workaround is:
Code: Select all
rsync -ruv ~/Programming/Python/* username@raspberry-IP:Programming/Python

which, at least in my eyes, is more clear.

To find the IP of the raspberry you can run:
Code: Select all
nmap -sP

or something similar (say ). nmap will need to be installed first of all.
You probably know the IP already (and perhaps there are much easier ways to find the right IP).
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am
by stevep » Sat Jul 07, 2012 10:55 am
nadir wrote:To copy them from VirtualBox to Windows and then from Windows to the raspberry seems a bit awkward.

I agree it seems a bit awkward, but in reality it is just a couple of drag n drops in a gui environment, which I thought would be better suited to one who says he is a novice (as I am myself). The tricky bit for a novice will be getting Samba to run. From my point of view your solution seems to be even more involved as it involves installing a program on the Win box, plus another program on both the Win and the Pi, followed by some command line stuff which has the potential for errors. So which is the best solution? Answer: neither. The other suggestions from Bredman and Toxibunny of emailing or Dropbox are far simpler for a novice (like me) to understand, so hats off to them for being able to truly consider the question from the OP's standpoint.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by kcranley » Mon Jul 16, 2012 3:14 pm
Many thanks to all for great advice. What I am now doing is using my Gmail to email myself files (from PC to Pi and Pi to PC!). This works great for all kinds of files, and if I need to print a listing from Geany, I just print it to a PDF file, and email myself that, so that I can then print it on my PC. The PDF is great as it gives the Geany listing in colour. Easy!!
Posts: 16
Joined: Fri Jan 20, 2012 10:33 am