For Python programming, you need a working Python installation and a text editor. Python comes with its own editorIDLE, which is quite nice and sufficient for the beginning programmer. As you get more into programming, you will probably switch to some other editor likeemacs,vi or another editor.
The Python download page is:https://www.python.org/downloads/. The most recent version is Python 3.10.6 (as of 8th August 2022);Python 2.7 and older versions will not work with this tutorial. There are various different installation files for different computer platforms available on the download site. Here are some specific instructions for the most common operating systems:
To install everything you need to run this curriculum, which includes Python 3, Python 3 setup tools, and the Barobo Python package, make sure you have an internet connection and run these commands in a terminal window:
sudoapt-getinstallpython3python3-setuptoolspython3-numpyidle3sudoeasy_install3pybarobo
You will also have to add your user account to the "dialout" group. You can do this by using the command:
sudousermod-a-Gdialout$USERThe above command will add whatever user you are logged in as to the "dialout" group. If you wish to add a user account that is not the one that is logged in, replace "$USER" with the user name of the other account. You may have to log out and log back in for the change to take effect.
For other distributions of Linux, follow the instructions provided by either your distribution or on the Python website to getPython 3,NumPy, andPyBarobo installed.
Raspbian comes with Python 3 and numpy installed by default. To get the Raspberry Pi ready to control the Linkbot, make sure your Pi is connected to the internet and type the following commands:
sudousermod-a-Gdialout$USERsudoapt-getinstallpython3-setuptoolssudoeasy_install3pybaroboYou may have to log out and log back in again for the changes to take effect.
Starting from Mac OS X (Tiger), Python ships by default with the operating system, but you will need to update to Python 3 until OS X starts including Python 3 (check the version by startingpython3 in a command line terminal). Also IDLE (the Python editor) might be missing in the standard installation. If you want to (re-)install Python, get the MacOS installer from thePython download site.
Download the appropriate Windows installer (thex86 MSI installer, if you do not have a 64-bit AMD or Intel chip). Even if you do have a 64-bit chip, I would still recommend downloading the 32-bit version because some of the Barobo Linkbot libraries are pre-built for 32-bit system by default. Start the installer by double-clicking it and follow the prompts. Be sure to include the optional package "pip", which can come in handy for installing additional Python modules and add-ons.
Once Python is installed and the path is configured, open a command prompt and type the following command:
pipinstallpybarobo
Seehttps://docs.python.org/3/using/windows.html#installing-python for more information.
The PATH environment variable is a list of folders, separated by semicolons, in which Windows will look for a program whenever you try to execute one by typing its name at a Command Prompt. You can see the current value of your PATH by typing this command at a Command Prompt:
echo %PATH%
The easiest way to permanently change environment variables is to bring up the built-in environment variable editor in Windows. How you get to this editor is slightly different on different versions of Windows.
On Windows 8: Press the Windows key and typeControl Panel to locate the Windows Control Panel. Once you've opened the Control Panel, select View by: Large Icons, then click onSystem. In the window that pops up, click theAdvanced System Settings link, then click theEnvironment Variables... button.
On Windows 7 or Vista: Click the Start button in the lower-left corner of the screen, move your mouse overComputer, right-click, and selectProperties from the pop-up menu. Click theAdvanced System Settings link, then click theEnvironment Variables... button.
On Windows XP: Right-click theMy Computer icon on your desktop and selectProperties. Select theAdvanced tab, then click theEnvironment Variables... button.
Once you've brought up the environment variable editor, you'll do the same thing regardless of which version of Windows you're running. UnderSystem Variables in the bottom half of the editor, find a variable calledPATH. If there is one, select it and clickEdit.... Assuming your Python root is C:\Python34, add these two folders to your path (and make sure you get the semicolons right; there should be a semicolon between each folder in the list):
C:\Python34C:\Python34\Scripts
Note:If you want to double-click and start your Python programs from a Windows folder and not have the console window disappear, you can add the following code to the bottom of each script:
print("Hello World")#stops console from exitingend_prog=""whileend_prog!="q":end_prog=input("type q to quit")
| Learning Python 3 with the Linkbot | ||
| ← Authors | Installation and Setup | Intro → |