Windows: WSGI Proxy "Server" Error on Canopy 1.3/1.4 startup

(Updated May 16, 2014)

After installing Canopy 1.3, a few users (especially in non-English locations) may be unable to start Canopy, and instead will see an error message like this:

WSGI Proxy "Server" Error. ... 'ascii' codec can't decode byte

Our apologies for the trouble. We've discovered that this is due to an old unfixed unicode-handling bug in Python 2.7 itself, when users have non-ASCII (i.e. non-English) characters in some Windows registry entries. The bug is fixed in Canopy 1.5 (due in June; it had been fixed for 1.4 but the fix was dropped, sorry!)

Meanwhile, you should be able to fix it manually by simply downloading and copying one file (these instructions are for Windows 7 or 8; the fix is similar for Windows XP):

1) Download the file attached to the bottom of this article (mimetypes.py) to your desktop.

2) Set Windows Explorer to show hidden files (on Windows 7: Computer / Organize / Folder & Search Options / View / Advanced settings / Show hidden...)

3) In Windows Explorer, locate the following directory:

Canopy 64-bit version on Windows 7 or 8 (if installed for current user):

C:\Users\<your-user-name>\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\Lib\

Canopy 32-bit version on Windows 7 or 8 (if installed for current user):

C:\Users\<your-user-name>\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.3.0.1715.win-x86\Lib\

Canopy 64-bit version on Windows 7 or 8 (if installed for all users, to default path):

C:\Program Files\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86_64\Lib\

Canopy 32-bit version on 32-bit Windows 7 or 8 (if installed for all users, default path):

C:\Program Files\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86\Lib\

Canopy 32-bit version on 64-bit Windows 7 or 8 (if installed for all users, default path):

C:\Program Files (x86)\Enthought\Canopy\App\appdata\canopy-1.3.0.1715.win-x86\Lib\

4) Check this directory to make sure that it has a file already in it named "mimetypes.py". If it does not, then you are not in the correct directory.

5) Copy the mimetypes.py file from your desktop to the directory that you just found. It will overwrite the existing file of the same name.

6) Start Canopy.

 

(FYI, optional): If you want to double-check what you just did and you know how to use an editor, lines 250 and 272 of the old (buggy) version of this file say (after indentation):

except UnicodeEncodeError:

whereas in the new (fixed) version, they say:

except UnicodeError:

 

Attachment:

Have more questions? Submit a request

Comments

  • Avatar
    xd dong

    The file in Canopy 1.4 (64) is  still not replaced with new mimetypes.py  !

  • Avatar
    Jonathan March

    @xd Confirmed, sorry! Investigating now.

    Update: build patch process error.

  • Avatar
    Garrett Lundy

    I did exactly as the steps, but the error remains.

    Canopy Version:

    canopy-1.4.0-win-64 express

    Error Msg:

    (http://help.canopy/welcome.html) WSGI Proxy "Server" Error.

    must be string without null bytes or None, not str

  • Avatar
    Jonathan March

    @Garrett - converting to support ticket for investigation.

  • Avatar
    Chris

    I have Canopy 1.3 installed on Windows 7 64-bit, and I don't find the path you listed. Under C:\Users<your-user-name>\AppData\Local\Enthought\Canopy\, it only has User and System, no App. If I do a search, it does not have mimetypes.py anywhere either. Are you sure this is the right version or path?

  • Avatar
    Jonathan March

    @Chris, Probably you installed for all users, not for current user. I have updated the article to include this possibility.

  • Avatar
    Haidar AlMubarak

    I tried this but it didn't solve the problem. I checked the content of the file and indeed the 

    except UnicodeEncodeError:

    was replaced by 

    except UnicodeError

    but I still get the error

    (http://help.canopy/welcome.html) WSGI Proxy "Server" Error.

    must be string without null bytes or None, not str

     

    I tried to uninstall it and change the system locals setting to English then install it again; I got the same error even after replacing the file.

  • Avatar
    Hernan Avella

    I have the same issue than Haidar AlMubarak. 

    (http://help.canopy/welcome.html) WSGI Proxy "Server" Error.

    must be string without null bytes or None, not str

    I live in the states, my User name is normal......I don't know what the problem is. The solution in this thread does not apply, but I comment here because the error I get is mentioned.

  • Avatar
    Tamara de Heij

    I too have the same issue. I followed the instructions, no solutions unfortunately. I'm in the Netherlands, I don't see a reason why I should have non-ASCII characters.

    Any help would be appreciated.  Thanks. 

    (http://welcome.canopy/welcome.html) WSGI Proxy "Server" Error.

    must be string without null bytes or None, not str

  • Avatar
    Tobias Thurnreiter

    I was having the same problem and after some searching I found out that apparently corrupted registry keys (containing illegal null characters) are the problem. Running the RegDelNull utility [1] from Microsoft as "regdelnull.exe hklm -s" solved the problem for me.

    [1] https://technet.microsoft.com/en-us/sysinternals/bb897448.aspx

  • Avatar
    John Wyant

    Just want to add that this issue is still happening with the latest version of Canopy Express 1.5.2.2785, using Windows 7 SP1 32-bit. Just fired up my Windows version of 1.5.1 for the first time in months ... and received the WSGI Proxy "Server" Error. Uninstalled Canopy and rebooted, then installed the latest version 1.5.2.2785. Same error. Found this thread, checked the "mimetypes.py" lines 250 & 272. They are the correct version.

    Solution: Tobias Thurnreiter last post was the fix that worked for me. All is well now!
    [1] https://technet.microsoft.com/en-us/sysinternals/bb897448.aspx

  • Avatar
    John Wyant

    For a follow up on my last post, the RegDelNull.exe found and fixed 21 registry entries with nulls ... the Command Prompt entries and responses for running this Microsoft utility are:

    C:>regdelnull.exe hklm -s

    RegDelNull v1.10 - Delete Registry keys with embedded Nulls
    Copyright (C) 2005-2006 Mark Russinovich
    Sysinternals - www.sysinternals.com

    Null-embedded key (Nulls are replaced by '*'):

    HKLM\SOFTWARE\Classes{03223D4D-1B28-4325-9A96-9C5A4C8EA8BC}*

    Delete? (y/n) y
    Key successfully deleted.

  • Avatar
    John Wyant

    As a final footnote, I googled a couple of the affected registry entries. Several folks have been having problems with their Python installations that this RegDelNull tool has fixed. One discussion points to an app that several of us have in common that may be the cause of the registry corruptiuon. The FastPictureViewer Codec Pack allows the windows file browser to view thumbnails and previews for non-native graphic file extensions. It's great for Photoshop users to see previews of their .psd files in Windows. My Canopy install used to work just fine, but I added this Codec Pack recently. The good new is that it still works after fixing the registry. The related forum is here: http://www.swarley.me.uk/blog/2014/04/23/python-pip-and-windows-registry-corruption/comment-page-1/

  • Avatar
    Jonathan March

    John, thanks for your comments and sorry that they were lost in the plumbing for a month! We'll follow up ASAP.

  • Avatar
    Jonathan March

    John, the fix for this is in Python 2.7.10, which I expect will be the foundation of Canopy 1.6.1, to be released in October.

Powered by Zendesk