Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to install Python and Myro on OS X for the Scribbler Bot.

Get Myro on Mac

There have been some issues getting everything properly installed for the Scribbler Bot project on OS X. It worked for me the first time because I used Homebrew and pip instead of the .mpkg installers. I've done this three times now and it has worked every time, so this should work for you too.

All code blocks are meant to be pasted into the Terminal.

Disclaimer: Follow these instructions at your own risk. I promise they won't do anything bad, but I don't guarantee it. I am not responsible for any unintended consequences.

Remove MacPython

If you already installed MacPython, you need to get rid of it.

1. Remove the application directory:

sudo mv "/Applications/MacPython 2.4/" ~/.Trash

2. Remove the framework:

sudo mv /Library/Frameworks/Python.framework ~/.Trash

3. Remove the symlinks (very important):

cd /usr/local/bin/ && find . -type l | while IFS= read -r lnk; do if (readlink "$lnk" | grep -q '^/Library/Frameworks/Python.framework'); then rm "$lnk"; fi; done

Fix your PATH

MacPython has taken it upon itself to change your path.

open -e ~/.bash_profile

There should be a couple comments (starting with #), a line beginning with PATH=, and finally export PATH. Remove all that, and replace it with this:

export PATH=/usr/local/bin:$PATH

This will ensure that your locally installed packages (such as Python) are preferred over system binaries.

Get Homebrew

If you don't already have Homebrew, you need to get it. It is a very useful thing to have if you are a developer working on a Mac. Install it now:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Get Python 2.7

You used to have two Pythons: the system Python, and MacPython. We got rid of MacPython in the first step. The system Python won't work for us, and it isn't kept up to date. Get the latest Python 2.7:

brew install python

This will take a few minutes. Don't install python3, because Myro doesn't work with Python 3.x.

Verify symlinks

After it's installed, make sure it gets symlinked:

brew link python

Now, which python should print /usr/local/bin/python, and which pip should print /usr/local/bin/pip.

Install Myro's dependencies

Myro depends on a few Python libraries. Install them:

pip install numpy pyserial Pillow

Checkout the Myro source

Go to your desktop with cd ~/Desktop, then checkout Myro:

svn co http://svn.cs.brynmawr.edu/Myro/trunk myro

There is a problem in Myro when it tries to import ImageTK, so I've created a patch and included it in this Gist. Scroll down, right-click on the "Raw" button in the top-right corner of myro-imagetk.diff, and choose "Download Linked File." Now, cd ~/Desktop/myro and apply the patch:

patch -p0 -i ~/Downloads/myro-imagetk.diff

Install Myro

Still in ~/Desktop/myro, run the setup script:

python setup.py install

Pair with Fluke2

Turn on your Scribbler Bot. Go to System Preferences > Bluetooth and pair with the Fluke2 chip. It should have a name that looks something like "Fluke2-0530."

Now that you are paired, find the port ID:

ls /dev/tty.*

One of the items in this listing should look like /dev/tty.Fluke2-0530-Fluke2 (but it will have different numbers in it). Copy this entire path to your clipboard.

Test Myro

Fire up a Python REPL simply by entering python in the Terminal. When you see the >>> prompt, import Myro:

from myro import *

You should see Myro version 2.9.9 is ready! before the prompt returns. Next, upgrade Scribbler:

upgrade("scribbler")

A dialog window will open, prompting you for a port ID. Paste the path that you copied in the previous step and click OK. Finally, initialize Myro, making sure to replace the string argument with the path that you copied:

initialize("/dev/tty.Fluke2-0530-Fluke2")

Now try executing some commands:

forward(1)

With any luck, your Scribbler Bot will start driving forward!


License

© 2014 Mitchell Kember

This document and myro-imagetk.diff are available under the MIT License.

Index: myro/graphics.py
===================================================================
--- myro/graphics.py (revision 1736)
+++ myro/graphics.py (working copy)
@@ -133,7 +133,7 @@
print >> sys.stderr, "WARNING: Image not found; do you need Python Imaging Library?"
try:
- import ImageTk
+ from PIL import ImageTk
except:
print >> sys.stderr, "WARNING: ImageTk not found; do you need the TkInter Library?"
@JoshuaA9088

This comment has been minimized.

Show comment Hide comment
@JoshuaA9088

JoshuaA9088 Jan 2, 2018

I'm getting this error: AttributeError: 'Serial' object has no attribute 'setTimeout'
Any suggestion?

I'm getting this error: AttributeError: 'Serial' object has no attribute 'setTimeout'
Any suggestion?

@Nemoha

This comment has been minimized.

Show comment Hide comment
@Nemoha

Nemoha Jan 20, 2018

When I use this
svn co http://svn.cs.brynmawr.edu/Myro/trunk myro
I'm getting this error
svn: (there is a number here): Unable to connect to a repository at URL 'http://svn.cs.brynmawr.edu/Myro/trunk'
svn: (there is a number here): nodename nor servname provided, or not known

Nemoha commented Jan 20, 2018

When I use this
svn co http://svn.cs.brynmawr.edu/Myro/trunk myro
I'm getting this error
svn: (there is a number here): Unable to connect to a repository at URL 'http://svn.cs.brynmawr.edu/Myro/trunk'
svn: (there is a number here): nodename nor servname provided, or not known

@AlisonRosenzweig

This comment has been minimized.

Show comment Hide comment
@AlisonRosenzweig

AlisonRosenzweig Feb 21, 2018

@JoshuaA9088, I encountered that error. The problem for me was that Myro uses an older version of pyserial and refers to the "setTimeout" attribute that they got rid of in later versions (3.0 I think). Using pyserial version 2.7 should do the trick

@JoshuaA9088, I encountered that error. The problem for me was that Myro uses an older version of pyserial and refers to the "setTimeout" attribute that they got rid of in later versions (3.0 I think). Using pyserial version 2.7 should do the trick

@JoshuaA9088

This comment has been minimized.

Show comment Hide comment
@JoshuaA9088

JoshuaA9088 Apr 5, 2018

@AlisonRosenzweig That does appear to be the issue. Pyserial v2.7 works.Thank you!

@AlisonRosenzweig That does appear to be the issue. Pyserial v2.7 works.Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment