It's possible that you need to explicitly include the pyserial module in your  It may also require a workaround similar to this one for the PIL libraries: -> figure out what pyserial is checking the string value 'loop://' against and import that constant in one of your modules to ensure that it gets bundled when you compile to exe.


On Thu, Jul 10, 2014 at 3:21 PM, Nikos Koukis <> wrote:

My name is Nikos Koukis. 
I have developed a python script for serial communication with a digital pump as a project in my university. 
The script seems to run properly when run under python and when I try to convert it to .exe the procedure doesn’t raise any error.
However when running the produced .exe I have the following error message:
File: serial\__init__.pyc in line 71 in serial_for_url
ValueError: invalid URL protocol 'loop' not known
The relevant part of the code is the following:
        self.ser = serial.Serial(port = port_name,\
                baudrate = 9600,\
                parity = 'N',\
                stopbits = 1,\
                bytesize = 8,\
                timeout = self.timeout_time)
    except serial.SerialException:
        self.ser = serial.serial_for_url('loop://',\
              timeout = self.timeout_time) # This line BLOWS!
        print sys.exc_info()[0]


It seems that after the production of the .exe file, the serial.serial_for_url(‘loop://') line doesn’t work at all.
Is there any open issue on bugs when using pyserial and py2exe? 
Is there any workaround which I could use?

Nikos Koukis
School of Mechanical Engineering
National Technical University of Athens
+30 6979852969

Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
Py2exe-users mailing list