Pyinstaller 1.5 with Python 2.6 (Round 3)

Round 1 with Pyinstaller 1.2 and Python 2.4 was here: PyInstaller1.2
Round 2 with Pyinstaller 1.3 and Python 2.5 was here: PyInstaller Round 2

Overview:

  1. Put latest copy of pyinstaller under the appropriate python folder e.g. Python26
  2. Run Configure.py e.g.

    C:\Python26\python.exe C:\Python26\Pyinstaller-1.5\Configure.py

  3. Make a dev folder and put main script in there and a copy of the most recent spec file made for any other project. Use as a starting point.
  4. Make a bat file to produce the executable using the spec file to configure the end result e.g.

    "C:\Python26\python.exe" "C:\Python26\pyinstaller-1.5\Build.py" "myproj.spec"
    pause

    Include the pause so any errors can be spotted and fixed

  5. Make another batch script which runs the executable and has the pause command at the end so you can spot any errors and fix them (so screen doesn’t flash on and off without giving you a chance to read the error messages if any). NB no python.exe involved – just the exe you made e.g.

    myproj.exe
    pause

  6. Once testing is complete, remake the exe with live spec settings i.e. set console to False and debug to False.
  7. Distribute 🙂

Mistakes to avoid:

  • Testing the exe with a batch file is good. Having the batch file try to run the exe with python, not so good (in fact, it is dumb 😉 ). Just run the exe on its own. Otherwise spurious error about encoding problem with line 1 of the exe. See Why this SyntaxError
  • If making a script which execs everything else it needs (reason: to keep things flexible), the main script e.g. “exec_script2exec.py” MUST import anything needed by scripts it is likely to call otherwise they will not appear in the exe. Pyinstaller can’t read minds or predict the future 😉 . So import wx and import win32com.client are probably required for my MS Access project. Otherwise will get an error about no module called wx etc.

Escaping Ubuntu Unity (for now)

Don’t get me wrong – I’m really looking forwards to what Unity will become (if Canonical plays its cards right). But it is a mixed experience for users at the moment. A friend of mine upgraded his laptop from Maverick to Natty and had some serious problems. Unity had worked at first (although he preferred the old interface) but then it stopped. The launcher and the panel vanished and he needed some help escaping Unity and using the Ubuntu Classic (Gnome 2) interface. Unfortunately, he wasn’t able to simply log in and change to Ubuntu Classic as per HowTo: Disable Ubuntu Unity Interface.

The first thing I suggested was that he follow the instructions at Missing top and side panels in Unity, Natty Troubleshooting. Great! It worked and now he could interact with the system much easier. The sharks were backing off 😉 (See http://xkcd.com/349/).

But how could he get the system to let him log in using his name and password? For that I needed the control panel. The easiest way to get that seemed to be via the terminal with the command:

gnome-control-center

Once there I could select the default log in session:

Change default log in session

Success!

While I’m at it I should add a couple of opinions about Unity. Why not? Everyone else is 😉

  1. Canonical needs to give users the option of Ubuntu Classic (Gnome 2) for a few releases more than intended. Depending on how Unity works with dual widescreen monitors I may need Gnome 2 for quite a while.
  2. Users need to have a few configuration options easily available – e.g. how to remove the overlay scroll bars**
  3. Unity could be awesome and I think it will be a great option within a couple of releases. See a reasonably balanced review here – Riding the Narwhal: Ars reviews Unity in Ubuntu 11.04 I am already trying out Oneiric Unity on my notebook so I’m not a hater.

**
At the moment you have to do the following:
sudo su
echo "export LIBOVERLAY_SCROLLBAR=0" > /etc/X11/Xsession.d/80overlayscrollbars

from How To Disable The Overlay Scrollbars In Ubuntu 11.04 [Quick Tip]

Telecom USB modem on Lucid Ubuntu

My mother runs Ubuntu (Lucid) on her laptop and she needed to make her NZ Telecom USB modem work. Getting an XT USB Modem working in Ubuntu provided a great starting point but there were a few things I had to do differently. I recommend printing the Rob the Geek article and then following this post for extra guidance.

The key issue is:

[these particular devices] respond to the system by default as a CD drive or USB hub so Ubuntu (with the stick in it’s native form) doesn’t see it as a modem device.
Getting an XT USB Modem working in Ubuntu

Fortunately, I had the option of dual booting into Windows XP so I could modify the modem (thus enabling Ubuntu to detect it as such). The missing step in the documentation for me was that I needed to install the modem under Windows first before I could see it in the Device Manager. In Windows XP, it was Control Panel>Classic View>System>Hardware Device Manager. I discovered the relevant port in my mother’s case was COM5. Yours may be different.

I used Hyperterminal for the next step. It wasn’t exactly intuitive to me but I got it to work. My main problem was I couldn’t see the interface responding as I typed in the command – at least not until it was entered. The command IIRC was AT+ZCDRUN=8

Hyperterminal command

I received:

>> Close autorun
state result (0: FAIL 1: SUCCESS): 1
>> OK

I could then reboot into Ubuntu. The Ubuntu steps (look at Rob the Geek’s instructions) “Just Worked” and the modem just works. I was also successful getting another Telecom XT mobile going for my father-in-law on his eeebuntu netbook. So this was not a fluke.

In conclusion, there was only one small thing stopping everything else from working. Once fixed – complete success and an easy and intuitive user interface.

Great new book on wxPython available

wxPython 2.8 Application Development Cookbook” is out and my first impressions are very positive. Although I already have a heavily-used copy of “wxPython In Action” I didn’t hesitate to add this new book to my collection. My open source SOFA Statistics application (36,000 downloads to date) is based on wxPython and is running successfully on Windows XP, Windows 7, Mac OS X, Ubuntu, Fedora, Linux Mint, Mandriva, Arch Linux and OpenSuse. This would not have been possible without a good cross-platform GUI toolkit and a helpful community to go with it. Good reference material has often proved essential as well and I look forward to putting this book to work in coming months.

wxPython Cookbook cover image

SOFA Statistics finally launched for general use!

SOFA Statistics is a user-friendly open source reporting, analysis and reporting package. The project goals are ease of use, learn as you go, and beautiful output. And after 34,000 downloads of early releases, the first general release of SOFA Statistics is out. See it in action here. You can get it for Windows, Mac, Ubuntu, and (other) Linux distributions here.

Version 1.0 launched

SOFA Statistics is 100% free and open source but affordable commercial support is available to those who would like that here. The latest version is the culmination of several years work and we hope you like it!

Installation note if upgrading: if upgrading from 0.9.24 or below, you will need to rename your /home/username/sofa folder to /home/username/sofastats if you wish to work with old data or settings. If you are using Ubuntu, you must also manually uninstall previous versions of SOFA first so that “sofastats” can overwrite the application icon put there originally by “sofa”.

OpenShot – Finally, decent video editing for Linux

Using OpenShot I was able to make videos, edit them, insert new sections, add soundtracks, make a groovy 3D title sequence (using Blender behind the scenes). I exported output as AVIs and MP4s, was able to select a size format that perfectly suited my target (www.showmedo.com), and was able to work it all out without reference to the documentation. So this is a big vote of confidence in a brilliant project with a bright future. The developer is very talented (and not just as a developer, but also as a promoter etc) and I think it is safe to hitch my wagon to that program.

The few glitches I experienced were not very large and will probably not survive for too long.

As an example of what I was able to do with OpenShot, check out the Quick Overview video here:

SOFA taster video

Button click bug not GDK_NATIVE_WINDOWS

There was a persistent bug in SOFA Statistics regarding the Preferences bitmap button (wxPython). You would click the button and it would not activate. The associated image would change when you hovered the mouse over the button and the button would appear to have the focus but no click event would fire. Pressing the Enter key or space bar would activate it. Aha! I knew of a similar bug that had affected eclipse on Ubuntu (see What GDK_NATIVE_WINDOWS=1 means) – and setting the env variable GDK_NATIVE_WINDOWS to true was the workaround there. Would that work? Well it did under some circumstances and not others. Very frustrating. But also very interesting now that I know the underlying cause of the bug – namely, a missing event.Skip() at the end of the event triggered by moving the mouse over the Preferences bitmap button. That’s all it was. Nothing whatsoever to do with GDK_NATIVE_WINDOWS really. Adding that missing line solved the problem.

Shifting to a new hard drive (using Ubuntu Live CD)

I needed to shift the contents, bit for bit, from a 1TB HDD to a 1.5TB HDD. The process takes several hours and may be best completed as an over-nighter.

Boot into a Ubuntu Live CD
Choose to Try It (not Install It)
Applications>Accessories>Terminal
sudo su (so we don’t have to use sudo all the time)
cfdisk /dev/sda (so we can see which HDD is which – it is VERY important to get the source and destination details the right way around)
cfdisk /dev/sdb (in my case it was 1.5TB and had no partitions so sdb was the destination for me. NB to get this the right way around)
dd if=/dev/sda of=/dev/sdb bs=30M & (‘dd’ for disk duplicator; ‘if’ is the source – ‘if’ for input file; ‘of’ is the destination – ‘of’ for output file; bs is block size and I chose 30M; & so the process runs in the background without feedback)

To get feedback as the process runs we use the scary command “kill”, but only as USR1. All this does is say Hi to the process and we hear back how long it has been running and how much it has processed.

My process number was 4569 but yours will be different:

kill -USR1 4569

At the end there will be a message about the task, and the kill command will be told the process is not running any more.

In my case I also wanted to change to ext4, delete the swap partition on the new (1.5TB) HDD, resize the partition on the new HDD, resize the file system on the new HDD, and create a swapfile.

The best and easiest way to do this is probably to use gparted from within the live CD.

System>Administration>GParted Partition Editor

From this point on, use advice at own risk:

OK – the destination disk is potentially 1.5 TB but it is currently only making 1TB available. We need to delete the partition, then create a new one (which should start at the same position).

cfdisk /dev/sdb (the destination, which might be a in your case)

cfdisk

d for Delete to remove the appropriate partition
n for New to make a new one
p for primary
Enter to accept size suggested
b to set the disk as bootable (will show up under flags)
A capital W for write and then yes to confirm (not y but yes)
q to quit

NB make sure the drive you want to modify is unmounted (to prevent severe damage).

May need to reboot to read everything properly.

e2fsck -f /dev/sdb1 (the destination, which might be a in your case)

Re: e2fsck see e2fsck(8) – Linux man page
-f Force checking even if the file system seems clean.
-y might also be useful: Assume an answer of ‘yes’ to all questions; allows e2fsck to be used non-interactively

resize2fs /dev/sdb1 (the destination, which might be a in your case)

The next instructions must be treated with caution as they are my recollection of the steps taken.

Open and edit /etc/fstab

The column headings are: file system, mount point, type, options, dump, pass

Where I saw ext3 I changed it to ext4:

UUID= .../ ext4 relatime,errors=remount-ro 0 1

I commented out the swap UUID:

#UUID=... none swap sw 0 0

And added a swapfile line:

/swapfile none swap sw 0 0

After Ubuntu upgraded the kernel later on I needed to reboot into the old kernel and run:

sudo update-grub

to be able to boot in an ext4 system.

Everything is working well and there were no issues when I upgraded from Lucid to Maverick a few weeks later.

Farce from the MPAA

In Making law the good way Colin Jackson recounts a delightful incident at the Commerce Select Committee hearing submissions on the Copyright Amendment (Infringing Filesharing) Bill. I repeat it here for your pleasure:

The next submitter was NZFACT and the Motion Picture Association of America (MPAA). This was led by the MPAA’s managing director for Asia Pacific, Michael Ellis. He made much of the fact that he had flown from Singapore to New Zealand to talk to the Committee. Ellis tried to show a video to the Committee to explain how easy it was to download the movie “Boy”. The submission came dangerously close to farce as he repeatedly failed to make his laptop display the video. These attempts took up most of his allotted time. Eventually he managed to start the video without sound.

Colin’s entire piece is well worth a read.