Can you install Python on RPiOS. If this is possible, which version do you need to download.
python.org/downloads/
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
- DougieLawson
- Posts: 40579
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Python on RPiOS
All versions of Raspbian (since Wheezy) and RaspiOS already include an appropriate (and current when built) version of python2 and python3.
What are you attempting to do?
What are you attempting to do?
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
Re: Python on RPiOS
I have downloaded a couple of books on learning Python and how to write some basic programs.DougieLawson wrote: ↑Mon Jun 22, 2020 8:16 pmAll versions of Raspbian (since Wheezy) and RaspiOS already include an appropriate (and current when built) version of python2 and python3.
What are you attempting to do?
How do you start Python on RPiOS.
- DougieLawson
- Posts: 40579
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Python on RPiOS
There's an interactive development evironment (IDE) called Thonny in the menu. That's your best starting point for python.
Otherwise open an LXTerminal window, use nano /home/pi/mypythonprogram.py to edit your code then use python3 /home/pi/mypythonprogram.py and it will run. Trust me, Thonny is easier for beginners.
https://magpi.raspberrypi.org/articles/thonny
Otherwise open an LXTerminal window, use nano /home/pi/mypythonprogram.py to edit your code then use python3 /home/pi/mypythonprogram.py and it will run. Trust me, Thonny is easier for beginners.
https://magpi.raspberrypi.org/articles/thonny
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 633
- Joined: Sat Feb 24, 2018 4:09 am
- Location: Buffalo, NY, USA
Re: Python on RPiOS
EnterRaspberry Pi Micro wrote: ↑Mon Jun 22, 2020 8:26 pmI have downloaded a couple of books on learning Python and how to write some basic programs.
How do you start Python on RPiOS.
Code: Select all
python
Code: Select all
python3
If you like (or your book uses) IDEs, Thonny and Geany are part of the non-lite packages and can be found on the 'Programming' tab of the main menu.
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
Re: Python on RPiOS
Finally looks like I now have Python3 installed. I start Terminal and then type python 3 and then the following information is displayed.pfletch101 wrote: ↑Mon Jun 22, 2020 8:35 pmEnterRaspberry Pi Micro wrote: ↑Mon Jun 22, 2020 8:26 pmI have downloaded a couple of books on learning Python and how to write some basic programs.
How do you start Python on RPiOS.at the system command line for Python 2, orCode: Select all
python
at the system command line for Python 3. These will give you the relevant version of python's command line.Code: Select all
python3
If you like (or your book uses) IDEs, Thonny and Geany are part of the non-lite packages and can be found on the 'Programming' tab of the main menu.
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "licence" for more information.
>>>>
There are many pages of python code in many of the Pi Magazines like in the screenshot below, In this example how do I start to type in some of this code by starting python3, or would I need to start using Thorny Python IDE. But still not 100% sure how to start entering code using python3.

I have also downloaded MagPi Issue 53 which may also be a starting point as well.

The MagPi Essentials Make Games with Python, does interest me a lot, as I would also like to convert some simple BBC Micro games to python once I have a good understanding.

The graphics in this game are simple enough, with the design of the screens.

Any help here will be most welcome.
Re: Python on RPiOS
As mentioned use Thonny.
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
Re: Python on RPiOS
Thonny uses Python3
-
- Posts: 7446
- Joined: Sat Jan 12, 2013 3:01 am
- Location: Grants Pass, OR, USA
- Contact: Website
Re: Python on RPiOS
The Thonny IDE is not itself Python.....It is a tool to help you write and debug your Python code. As mentioned any text editor such as nano or mousepad could be used to write Python code, but an IDE has a lot more features to help you write and debug your code.Raspberry Pi Micro wrote: ↑Tue Jun 30, 2020 2:33 pmOk thank you, is this the same or slightly different version of python.
From the Thorny View menu, what should I have selected or shown.
Once your code is written and working, in most cases, the IDE is no longer needed and you just run your code from the command line or desktop like any other app or command.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.
Re: Python on RPiOS
Firstly please forget mentions of Python2. It was officially end-of-life six months ago.
Python3 is the only version of Python you need think about, and henceforth "Python" refers to Python3.
Python is a programming language much like any other. You write your program in an english like language that a human can understand, and it gets translated into a different language that only the computer can understand.
The program you write is just a simple text file that you can produce with any text editor. It is called "source" code.
You give the program to the Python translator (called an interpreter) which reads the english like text in, converts it into the machine language, and executes it. The interpreter is a computer program called "python3".
Python is slightly unusual in that you can enter an interactive mode (just by typing "python3") where you may type in commands and expressions directly and it will translate and execute them immediately. Makes a nifty calculator ....
Normally however, you would create a text file typically suffixed with ".py" such as "hello.py" with an editor. The file contains your program.
Then you type "python3 hello.py" and it will run your program. (You can avoid typing the initial python3 all the time).
As noted above, you can use literaly any text editor you like, there are many to choose from. Nano on the Pi is fine and simple to use.
There are also various IDE's where you edit your program, run it, debug it etc all in the same place (that's why they are called Integrated Development Environments - IDE). The editors within these IDE's may offer better facilities for Python source such as highlighting keywords in different colours etc.
Python3 is the only version of Python you need think about, and henceforth "Python" refers to Python3.
Python is a programming language much like any other. You write your program in an english like language that a human can understand, and it gets translated into a different language that only the computer can understand.
The program you write is just a simple text file that you can produce with any text editor. It is called "source" code.
You give the program to the Python translator (called an interpreter) which reads the english like text in, converts it into the machine language, and executes it. The interpreter is a computer program called "python3".
Python is slightly unusual in that you can enter an interactive mode (just by typing "python3") where you may type in commands and expressions directly and it will translate and execute them immediately. Makes a nifty calculator ....
Code: Select all
$ python3
Python 3.7.2 (default, Jan 9 2019, 15:51:37)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 + 2
4
>>> print("Hello world!")
Hello world!
>>>
Then you type "python3 hello.py" and it will run your program. (You can avoid typing the initial python3 all the time).
As noted above, you can use literaly any text editor you like, there are many to choose from. Nano on the Pi is fine and simple to use.
There are also various IDE's where you edit your program, run it, debug it etc all in the same place (that's why they are called Integrated Development Environments - IDE). The editors within these IDE's may offer better facilities for Python source such as highlighting keywords in different colours etc.
Pi4 8GB and Pi4 4GB running Raspberry Pi OS 64-bit
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
Re: Python on RPiOS
Thank you. Think I will start with Thorny Python IDE, from the menu at the top, you select View, this it gives you a number of views options, what should I best select here to start with.klricks wrote: ↑Tue Jun 30, 2020 3:33 pmThe Thonny IDE is not itself Python.....It is a tool to help you write and debug your Python code. As mentioned any text editor such as nano or mousepad could be used to write Python code, but an IDE has a lot more features to help you write and debug your code.Raspberry Pi Micro wrote: ↑Tue Jun 30, 2020 2:33 pmOk thank you, is this the same or slightly different version of python.
From the Thorny View menu, what should I have selected or shown.
Once your code is written and working, in most cases, the IDE is no longer needed and you just run your code from the command line or desktop like any other app or command.
Assistance
Exception
Files
Heap
Help
Notes
Object Inspector
Outline
Program Tree
Shell
Stack
Variables
Program Arguments
Plotter
Increase Font Size
Decrease Font Size
Focus Editor
Focus Shell
Only options I have selected are;
Shell
Varables
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
Re: Python on RPiOS
What options are there for taking a screenshot on RPiOS, if it's the whole screen or just an active window.
On Mac OS it's CMD + SHIFT + 3 and CMD + SHIFT + 4
On Mac OS it's CMD + SHIFT + 3 and CMD + SHIFT + 4
-
- Posts: 7446
- Joined: Sat Jan 12, 2013 3:01 am
- Location: Grants Pass, OR, USA
- Contact: Website
Re: Python on RPiOS
Pressing the [Print Screen] key will capture the entire screen and save a .png image in the current directory.Raspberry Pi Micro wrote: ↑Tue Jun 30, 2020 6:45 pmWhat options are there for taking a screenshot on RPiOS, if it's the whole screen or just an active window.
On Mac OS it's CMD + SHIFT + 3 and CMD + SHIFT + 4
For more options you can run scrot from the command line.
For details see:
Code: Select all
scrot -h
Code: Select all
man scrot
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.
-
- Posts: 102
- Joined: Mon Jun 15, 2020 7:59 am
-
- Posts: 7446
- Joined: Sat Jan 12, 2013 3:01 am
- Location: Grants Pass, OR, USA
- Contact: Website
Re: Python on RPiOS
Documented on RPi website:
https://www.raspberrypi.org/documentati ... /README.md
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.