Category Archives: Python

Python ‘pip’ and Windows registry corruption

Background

In my recent post about setting up a 64 bit Windows Django development environment, I described an initial problem with Virtualenv which then led me through a whole series of problems and fixes and finally to what I thought was a working 64 bit Python development environment. However, I recently realised that the original underlying issue still remained, such that any attempt to install a new package using pip would result in failure due to that same error message.

For example, when I tried to install Beautiful Soup via pip, I got the following error:

C:\> pip install beautifulsoup4
Downloading/unpacking beautifulsoup4
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run

requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl
e=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python27\lib\site-packages\pip\req.py", line 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.s
etup_py, self.name))
File "C:\Python27\lib\site-packages\pip\req.py", line 265, in setup_py
import setuptools
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 12, in
from setuptools.extension import Extension
File "C:\Python27\lib\site-packages\setuptools\extension.py", line 7, in
from setuptools.dist import _get_unpatched
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 15, in
from setuptools.compat import numeric_types, basestring
File "C:\Python27\lib\site-packages\setuptools\compat.py", line 19, in
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand
ler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 361, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 263, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: must be string without null bytes or None, not str

Continue reading Python ‘pip’ and Windows registry corruption

Create a Django development environment on 64-bit Windows for Heroku deployment

Getting Started with Django on Heroku

This weekend I tried to follow Heroku’s Getting Started with Django article. Unfortunately for me, this article is clearly aimed at developers working in a “unix-style environment”, and I develop with a 64-bit Windows machine both at work and at home. Given that we are working with a Python-based framework, I foolishly assumed that it would be trivial to translate these instructions to Windows. How wrong I was.

This article summarises all the issues I encountered and how I eventually worked around them. I found most of the individual answers I needed via Google, but I couldn’t find a single resource that explains this whole process. I hope it saves you some time. The specific error-messages and console output were generated with 64-bit Windows 8.1, but I expect things to be basically the same with 64-bit Windows 7.

Continue reading Create a Django development environment on 64-bit Windows for Heroku deployment