Python installation confusion on Mac OS X

19 Sep, 2013

Justin J writes:

I installed python 3.3.2 for my macbook running version 10.6.8 and typed this in, open -a "/Applications/Python 3.2/IDLE.app" --args -n and it didn't work:

"The action Run Shell Script encountered an error. Check the action's properties and try running the workflow again"

I installed both versions 32 bit and 64/32 bit and it still didn't work.

I'm assuming because I installed 3.3.2, I had to change it to open -a "/Applications/Python 3.3/IDLE.app" --args -n. In other words change Python 3.2 to Python 3.3. Then it worked! Unfortunately I think it was running on the 64/32 version which python mentioned something about ActiveTcl 8.5. It recommended I download 32, so I got rid of 64/32 and re-downloaded 32 bit and it finally gave me no error in the shell.

I thought I'd ask if this was an ok thing for me to do?

As per the instructions on this page, you'll need to install ActiveTcl in order for IDLE and Tkinter to work properly (both are used heavily in the book) with Mac OS X 10.6.

ActiveState have a dmg installation file, so once you've downloaded it, double-click on the file, and a dialog will appear:

ActiveTcl installation dialog

You may need to control-click on the ActiveTcl package, if you double-click and get the error message "ActiveTcl-8.5.pkg can't be opened because it is from an unidentified developer". So if that error message appears, hold down the Control key, click on the icon and select Open from the menu displayed, then click Open on the following screen. Click through the next few screens (you'll be asked to agree to the license and so on), and on the final screen, once you click Install, you'll get promoted for an administrator username & password.

Apart from that, your change to the open command is correct, so once ActiveTcl is installed, you should be good to go.


What is -n for

27 Aug, 2013

John writes:

Quick question regarding the -n used in the shortcut for IDLE. I realize that it starts IDLE with no subprocesses, but what does that mean and why do we want to do it?

There's precious little on the net describing what the -n switch does. From the IDLE documentation:

If IDLE is started with the -n command line switch it will run in a single process and will not create the subprocess which runs the RPC Python execution server. This can be useful if Python cannot create the subprocess or the RPC socket interface on your platform. However, in this mode user code is not isolated from IDLE itself. Also, the environment is not restarted when Run/Run Module (F5) is selected. If your code has been modified, you must reload() the affected modules and re-import any specific items (e.g. from foo import baz) if the changes are to take effect. For these reasons, it is preferable to run IDLE with the default subprocess if at all possible.

Which, I admit, doesn't help a huge amount...

For the purposes of Python for Kids however, all you really need to know is that certain graphical libraries (such as turtle and, I seem to recall, tkinter) will exhibit weird behaviour (such as locking up/hanging) if you don't run IDLE using the -n switch.


Tkinter problems on the Raspberry Pi

09 Jul, 2013

Ben writes:

I am 12 and I am reading your book, Python for Kids. I have recently confronted a problem with the module tkinter. I have recently got a rasberry pi to program on python. I am pretty sure that tkinter is already installed on python, but when I run something like:

def hello():     print('hello there') from tkinter import * tk = Tk() btn = Button(tk, text='click me', command=hello) btn.pack()

There is nothing that pops up! I am frustrated and need help! Please help, me and my father are new to linux by the way and don't know what to do.

Ben is using Debian Linux on his Raspberry Pi. After a bit of to-ing and fro-ing, we eventually found that tkinter was definitely installed, but it looks like (according to this stackoverflow question that his father found) the tkinter window doesn't appear unless you use: tk.mainloop().

So if you're trying the code on page 178 (for example) on a Pi, you might need to add one line to get it to work successfully:

###
>>> from tkinter import *
>>> tk = Tk()
>>> canvas = Canvas(tk, width=400, height=400)
>>> canvas.pack()
>>> canvas.create_arc(10, 10, 200, 80, extent=45, style=ARC)
>>> canvas.create_arc(10, 80, 200, 160, extent=90, style=ARC)
>>> canvas.create_arc(10, 160, 200, 240, extent=135, style=ARC)
>>> canvas.create_arc(10, 240, 200, 320, extent=180, style=ARC)
>>> canvas.create_arc(10, 320, 200, 400, extent=359, style=ARC)###
>>> tk.mainloop()

Python Kinderleicht

30 Jun, 2013

Python Kinderleicht cover This arrived in the mail from No Starch today.

Sehr cool!

The German translation of Python for Kids is available from the publisher dpunkt verlag and amazon.de (probably others, but those were the first couple of links that popped up).


On Feedly

28 Jun, 2013

Rather than burning a significant amount of time rolling my own alternative to the soon-to-be-lamented Google Reader, I've been evaluating the various closed and open source options, finally settling on Feedly.

feedly error screen It's... okay... but the mobile app (at least the iPhone version) isn't... well... particularly mobile. Sure, it looks pretty, and for the always-connected user (those irradiated with 100% 3G coverage), perhaps its shortcomings are a little easier to bear. But I spend a significant chunk of commute-time, sitting on a train, with an internet connection that bounces like the proverbial yoyo. Instead of downloading all articles when there's a good internet connection, Feedly just downloads the current feed (possibly a side effect of the way I use it - I like to go to the individual feeds and read all articles in a section, rather than the mixed articles it presents in the ALL tab). So on a typical commute home, I'm either presented with numerous error screens, or an interminable (so it feels) loading screen.

feedly loading screen To make things worse, the iPhone app seems to forget that it just loaded something (not always, but enough to be annoying). So if I flip from Feedly, to iMessage, and then back again... once again I'm presented with the loading screen. The forgetfulness isn't limited to loading - it also affects articles I've already read (or already marked as read), which Feedly inconveniently forgets and I get the same set of articles again.

feedly flick The interface seems a little inconsistent, as well. As I go through the articles in each feed, when I reach the end of the list, I'm presented with a large, friendly tick and a message telling me to "Tap to mark all articles as read". Which I do. The next feed appears and (after the loading screen) I flick the page up for the next article... except sometimes not. Despite the fact that there are plenty of unread articles, I can't flick to get to the next - I have to use the menu and find the next unread feed myself. Which might make sense if it was the last feed in a list sorted in alphabetical order. But it's not. So it makes no sense to me at all.

So, nice interface, but could use some work. A menu option, to download all articles when I've got a good connection (at home before leaving for work, for example). Remembering which article I was on last time, and not immediately trying to re-download just because the connection bounced in the meantime.

Still... better than Reader nothing...

Update: turns out that Reeder coupled with Feedly in the backend (for the moment) is the ideal solution.