User avatar
some_evil
Posts: 205
Joined: Thu Dec 18, 2014 3:16 am
Location: Albury, Australia

Can I SSH to Pi using Putty, then use Python Command Line?

Wed Jan 20, 2016 1:04 am

Hi All,

I usually use my PC to SSH onto my Pi using PuTTy, which is great.

When I want to run a simple python line I always use

Code: Select all

sudo nano newCode.py
Add my code... then run using:

Code: Select all

python newCode.py
and I get my output....

Sometimes I have to create the above python file to run a single line, this is time consuming.

Is there a way to enter some form of Python Command Line over this SSH connection???

Thanks
PiZeroW - May 2017
Pi 3 - Oct 2016
PiZero - June 2016
Pi 2 - Jan 2016
Pi B+ - Dec 25 2014

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Wed Jan 20, 2016 6:22 am

Try -c as noted in

man python

http://linux.die.net/man/1/python
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Wed Jan 20, 2016 6:22 am

Have you tried IDLE or just typing `python` at the command prompt to get the python CLI?
Account Inactive

User avatar
rpdom
Posts: 14987
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Wed Jan 20, 2016 7:00 am

some_evil wrote:When I want to run a simple python line I always use

Code: Select all

sudo nano newCode.py
Why do you use sudo here? It shouldn't be needed at all.

Using sudo with nano will create file that is owned by the user "root", instead of your "pi" user. That is pointless (unless you are editing system files) and can cause permission problems.

User avatar
some_evil
Posts: 205
Joined: Thu Dec 18, 2014 3:16 am
Location: Albury, Australia

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Wed Jan 20, 2016 7:15 am

sorry that was way easier than I imagined... i feel stupid now, simply typing python (nothing after it) will enter the command line for python.. works perfectly.

And yes you are correct, sudo is redundant in my example.

Thanks for the help guys, greatly appreciated, you just saved me plenty of wasted hours creating .py files for nothing! haha :roll:
PiZeroW - May 2017
Pi 3 - Oct 2016
PiZero - June 2016
Pi 2 - Jan 2016
Pi B+ - Dec 25 2014

Return to “Beginners”