Can I run and develop a python program from another computer?

Viewed 252

So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from.

Is it possible for me to write some python code on my Windows PC, "run" it on the Raspberry pi, and receive any outputs of the program on my Windows PC?

The reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)

I hope my question is in the right format and such! This is my first time posting! Any comments appreciated!

2 Answers

Yes you can do that, but it might not be very straight forward. In order to achieve this, you need your Raspberry Pi to be on the same network as your Windows PC (i.e. on the same WiFi network or connected via Ethernet). Then you need to get the IP address of your Raspberry Pi through the following command:-

ifconfig -a

The IP address will be of the following format: W.X.Y.Z

Now from your Windows PC, you can send your python script/scripts through the following command from cmd:-

scp script.py pi@W.X.Y.Z:/home/

And then you can access your Raspberry Pi and run the program by sshing into it through the following commands from cmd:-

ssh pi@W.X.Y.Z

You'll need to enter the Raspberry Pi's password for both commands above, but after that you should have your script on your Pi and you should be able to run it there from your Windows PC.

The links below have more verbose explanation:-

I hope this helps.

It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.

For anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often.

The scp command would also work, I think, but is more complex than what I want to do.

Thank you so much for the answer, JL Peyret!

Related