Can I program a Raspberry Pi with Python over SSH? [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
So, I know Python, and I've been thinking of getting a Raspberry Pi, as I heard that you can program it with Python. The thing is, I don't have an extra HDMI monitor at hand, but only a Windows 10 laptop (besides, what use would an R-Pi be if you want to use it in a project, when it has to be plugged in to a monitor, mouse etc.?), so I found an alternative called SSH. After watching a few tutorials, I'm positive that I'll be able to set up an R-Pi wirelessly with ease. However, it still hasn't become clear to me, how I would be able to program an R-Pi with Python over SSH.
My initial goal with the R-Pi is to program it with Python, to do things like from saying "hello world", to controlling the GPIO ports, all without external hardware (except that laptop), but I haven't found anything on the internet that suits my needs. Now, my question is, how do I do such, and to what extent will I be able to control my Pi with Python through another computer?
Thank you in advance for the help!

When you connect over ssh to a raspberry pi you are greeted with a terminal.
In that terminal you can use a command line editor like nano or vim to make and edit files. You can also use the command line to execute them.
In this little session I connect to a raspberry pi and then make a python program and execute it.
trirpi#mycomputer:~$ ssh pi#192.168.1.3
pi#192.168.1.3's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Dec 26 17:41:02 2016 from 192.168.1.83
pi#raspberrypi:~ $ ls
projects
pi#raspberrypi:~ $ cd projects/
pi#raspberrypi:~/projects $ vim aprogram.py
pi#raspberrypi:~/projects $ python aprogram.py
You should learn how to use the command line so you can use commands like cd.
You could also setup a vnc server (I think the new raspbian image has one installed by default). That way you can also see gui's and not only a terminal.

Related

A Real Talk About Python Software Distribution [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know this is a hot topic and many people ask this question but I have the feeling I am missing something. What is the proper way to make a python application for end-users? Like, old-school offline .exe and so on. Many users won't touch the terminal/shell and to be honest most software these days is incredibly easy to install. What I know so far:
There are packages out there that can make your software ready for redistribution like
pyinstaller, cx_freeze, py2exe
I wrote my fairly complex software in like 2 weeks and going crazy for days over making pyinstaller work with my external packages. Is this pain normal? Have I made a mistake by relying on an interpreted language? Because compiling this stuff is mean business. In many other languages you just build the stuff within the IDE and there you go, built.
I am not concerned that my code might be decompiled, so what I have tried is to just create a .bat file with commands to execute my script with my virtual environment(!) python. Can I just manage to have the Python venv in place with my scripts without the user having to install it himself?
Or what is the "usual" way to do this? Use Cython? Or pyinstaller? Praying to the lord of code?
FYI: I am using Python 3.6.8, Windows 8 (don't you dare making fun of me :D) and Pycharm 2019.2
However thank you in advance for your time, regards,
Arjaan
There is no correct or established way of how to create an executable file for your Python project. It's opinion-based.
And how you want to distribute your software is entirely up to you. It can be source code, compiled, as a docker image, through Heroku One-Click deployment, debian package, all of the above, ???.
Having choices is nice. Some people need a really simple solution then Heroku or an exe file is nice. Some people are Docker power users, then a multi-arch docker image is nice. Some people want to modify the source code than having the source code is nice. Some people like debian packages and want your project with a systemd service file automatically enabled and started.
You might also not put into the work of getting docker/debian/heroku to work and just tell them a step by step guide on how to get it to run.
Debian and Heroku route might require some periodic maintenance due to the Linux distros updating to newer versions.
There is so much to it and it is an endless discussion where noone is right or wrong.

Python before booting? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I was on freelancer website and I found this work proposal:
Project Description
Hello
We need experience developer in python.
Only bit that person who has a experience in python and Linux.
I want to execute python code in Booting time before execute Operating
System Desktop.
I know that unless I candidate, I won't have any detail about the project, but anyway it seems odd to me.
From my understanding python is interpreted, which means that it needs a virtual environment, and that's what makes it platform independent. Therefore how can a python script (which doesn't convert 1:1 to machine instructions) run before the operative system? Since I know little about what's going on at boot time (I guess some pre-defined instructions laying in the motherboard ROM are executed, then the bootloader loads in the RAM the OS, and the program counter holds the address for the entry point of the OS itself, but I am just supposing) I ask you whether such a thing could be possible.
Linux, being a UNIX type OS, has the concept of runlevels. Each runlevel has a certain number of services stopped or started, giving the user control over the behavior of the machine. As far as I know for Linux, seven runlevels exist, numbered from zero to six. The "Operating System Desktop" becomes available at run level 5. At boot time the system will pass through several other runlevels before getting to 5. At level 3 the system will be have Multi-User Mode with Networking, and this would be a good level to run what ever python script you need. Maybe check into configuring Linux init scripts.

How do you run a Python (.py) program by double clicking the icon? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
(I use Mac OS X and Python version 3.4.3).
When I double-click on the Python program (.py), I don't want the source code to load/open in Python IDLE, I just want the program to run in Python Shell?
For example when I click the Spotify Icon App, it just runs the program and doesn't bring up its source code! I understand this maybe a very simple question, but I am really stuck! Any help will be great! If this is unclear feel free to ask me questions.
TLDR: You don't.
This isn't normally done; applications that you double click are usually compiled so that the source code isn't there anymore, instead it's been turned into machine-readable instructions for the computer. Since python code is source code, it's simply not designed to be run like an app.
You can compile your python code into an app every time you want to use it, using something like py2app but then the source-code inside isn't easily editable and it may be fiddly to get complex imports working with this, or multiple python versions. I wouldn't get into the habit of this.
Instead, to run a python file, use the Terminal, and type python file_location where file_location is the path to the file. Alternatively you could navigate in the Terminal to the directory containing your python file and then just use python file_name where file_name is the name of your file.
Only compile your python work into an app when it's at its final stage and ready for "release".
For example, what if your app prints something to the command line? Without running it from the command line where would python print that information? Or what if something goes wrong in it and it returns an error; where would that error message go? Also the newer versions of Mac and their "System Integrity Protection" can make life difficult for bundled apps.

How do I install streamparse from source? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I need to use streamparse on a CentOS machine that does not have internet access, meaning I cannot use pip. The only net-enabled services I can use are scp and ssh. My plan is to get streamparse on my local machine (Ubuntu) and then scp the streamparse files to the CentOS machine and manually install from there.
Any ideas on how to do this?
edit:
since this is "on hold as off-topic," I'll explain why it just might be considered "on topic" by addressing the 4 "on topic" bullet points from the community help page (https://stackoverflow.com/help/on-topic).
a specific programming problem: installation is a kind of programming problem, especially when you have to write (program, verb) shell scripts (program, noun) to accomplish the installation of software that leads to more programming.
a software algorithm: I am looking for a sequence of steps (aka an algorithm) to install something within specified technical constraints.
software tools commonly used by programmers: the thing I am trying to
install is a software tool. It is called streamparse. It is used by programmers.
a practical, answerable problem that is unique to software development: I was not asking this question for theoretical reasons--hence it is practical, and I believe installing things by getting around firewalls is unique to software development. I'll concede that this could be viewed not as "software development" but rather "devops" but those two things are merging so throw me a bone here.
Once you have the lib files on the CentOS box you can use pip to install by passing the -e (editable) flag:
$ pip install -e path/to/SomeProject
Here's a link to pipy's #editable-installs section
Thanks, #dougdragon. I also got pointed to the solution below. I'll leave yours as the accepted answer since you got it first.
$ wget https://pypi.python.org/packages/8d/f8/9ccde77a90a30ef491bee431f157aee38dbd93b5f3c7545779a0acee71db/streamparse-3.0.1.tar.gz
$ tar -zxvf streamparse-3.0.1.tar.gz
$ python streamparse-3.0.1/setup.py develop

Installing Python on a remote UNIX machine [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need to run a Python script on a remote Linux machine. The problem is that Python isn't installed on that machine. As a newbie in Linux greedily taking advantage of the user friendly tools Ubuntu offers, I have no clue how to install it without a packet manager (God bless apt-get!). I don't even know if the OS running on the remote machine is Debian based, but I do know that it doesn't have apt-get installed.
I connect to it using SSH, have root rights, want to run my scripts on it continuously.
Please help me!
Thanks in advance!
as a normal user run the following commands:
wget http://www.python.org/ftp/python/2.7/Python-2.7.tgz
tar xzf Python-2.7.tgz
cd Python-2.7
./configure --with-pth --with-dec-threads --with-signal-module --prefix=/opt/python-2.7
make
then as root do (becoming root using sudo or su):
make install
A brief explanation:
wget downloads the python sources, you can install another version if you like, maybe python 3.x
tar uncompress the downloaded file
configure checks if all required dependances are available and configures the source code for your own system
make starts the compiling/linking process
make install copy the compiled file in the right place
after that maybe you need to make a symbolic link to your python executable or to your python folders, it depends on you
references:
- the installations commands have been copy-pasted from this website after a rapid google search, so maybe you need different config options
- the official info are here
note:
I this question should be better placed on superuser.com (the reason is that may be more relevant for computer enthusiasts & power users rather than for programmers, since it is not a programming issue but a software installation issue)

Categories

Resources