I'm posting this information to help others who are transitioning from Python 2.x to Python 3.x and are using Vim and Mercurial on Windows.

BACKGROUND

Old workstation configuration: 32-bit Windows XP/SP3, Python 2.7.6 and 3.3.3, Mercurial 2.8.2, PATH contained Python before Mercurial, dual boot with Slackware 14.0

New workstation configuration: 64-bit Windows 7/SP1, 64-bit Python 3.3.3, 64-bit Mercurial 2.8.2, PATH contained Python before Mercurial, dual boot with Slackware64 14.1

Early last year, I ported dozens of Python 2.7 tools that I wrote to automate various development tasks to Python 3 (via 2to3 script and testing). After the ports were completed, I had my colleagues replace their Python2 installations with Python3. We quickly uncovered/fixed a few issues (mostly related to Unicode) that I missed in my initial testing. We've been happily running the Python3 versions for months now, but I've been reluctant to remove Python27 from my old (soon to be retired) workstation.

PROBLEM

Yesterday, I finally decided to say goodbye to Python27 on Windows and uninstalled it from my old workstation. A little while later, I noticed that vim no longer worked. Gvim.exe silently failed and vim.exe failed with the following error:

ImportError: No module named site

After reading the relevant vim documentation (http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python-dynamic) and doing a few Google searches, I decided to run vim under windbg to see what was actually going on. Windbg showed that vim loaded the python27.dll from my Mercurial installation just before exiting. A quick look inside Mercurial's library.zip file showed that the site.py module was not included. OK, so now things were starting to make sense.

WORKAROUND

I took Mercurial out of the PATH, which returned vim to working order. I then wrote the following two line hg.bat script and copied it to a directory include in the PATH:

@echo off
"C:\Program Files\Mercurial\hg.exe" %*

With this workaround, both vim and hg appear to be once again working on the old workstation.

64-BIT WINDOWS

As the vim for Windows package I installed is a 32-bit application, I didn't have this issue on 64-bit Windows using 64-bit Mercurial. However, I believe the same issue would occur if 32-bit Mercurial is used on 64-bit Windows.

Hopefully this information is useful to other Python, Vim, and Mercurial users.

Peter Santoro
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to