Install Python 3
Python is a programming language, and needs to be installed on your computer before you can use it. How you do this depends on what operating system you’re running on your computer. Here are some good tutorials on how to install Python on specific systems, or how to start using it if it comes pre-installed, like on a RaspberryPi:
MartyPy is a Python library for Marty. Libraries are just collections of code that we’ve written that get all the complicated stuff out of the way, making it easier to use and work with. For example, MartyPy contains the definition of the “walk” function, which can be used to make Marty walk. If you’ve never used Python before, it’s well worth checking out one of the thousands of tutorials and videos online. Most people consider Python one of the easiest programming languages to learn, and a good level-up after mastering Scratch.
Ensure that you have Python 3 installed on your machine, and python virtual environments. Support for virtual environments, or venvs comes bundled with python on soe systems and not other, where they may need to be installed as a second step.
We recommend installing the latest version of Python 3. Python 2 will probably still work, but it is not supported.
If you’re using a Linux distribution, use whichever package manager you’d normally use to install
python3, though in all likelihood you’ll already have some version of Python 3 installed.
On a Mac, setup is pretty complex if you don’t already have Homebrew and XCode installed. Again, we’d strongly recommend you go find a tutorial for installing Python on a Mac, then come back - this might be a good start.
For Windows users, Python can be downloaded from python.org: Python Downloads
As a sidenote, if you don’t want to follow through installing MartyPy the ‘proper’ way using a virtualenv, then you can just type
pip install martypy and it’ll probably work…
If you don’t use Python for anything else, or are completely new to it then taking the simpler route might be easier for you.
Open a Terminal (Command Prompt). We’ll want to work from a project folder of some sort, so the first thing we’re going to need to do is make an empty directory and go into it:
Let’s make a project folder, which can be called whatever you want - I’m going to go with
you@computer:~$ mkdir martypy-tutorial
Move into it…
you@computer:~$ cd martypy-tutorial
Create a new Virtual Environment called VENV:
you@computer:martypy-tutorial$ python3 -m venv VENV
C:\Users\Username\martypy-tutorial>python -m venv VENV
And ‘activate’ it – You’ll have to activate your virtual environment each time you need to use your code and martypy and haven’t already done so in a particular window.
you@computer:martypy-tutorial$ source ./VENV/bin/activate
Finally, we can install martypy:
(VENV) you@computer:martypy-tutorial$ pip install martypy
C:\Users\Username\martypy-tutorial>pip install martypy
Once the last step is completed, MartyPy should be installed. To confirm this, we’ll open a Python Shell and try to import the library:
$ python3 Python x.y.z (default, Jan 1 1970, 00:00:01) Type "help", "copyright", "credits" or "license" for more information. >>> import martypy >>>
If no errors are displayed, you have successfully installed MartyPy! If you get an error (or Exception) that looks like this:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named martypy >>>
Then Python can’t find martypy. This is most likely because either 1) the Virtual Environment hasn’t been sourced, or 2) because you didn’t
pip install martypy.