pythoncvs2svn

How can I fix this Python script?


I'm trying to convert a CVS repository to Git using cvs2svn and am following the directions on this page. I got to step 7 but am getting an error running git-move-refs.py:

Traceback (most recent call last):
  File "../../cvs2svn-trunk/contrib/git-move-refs.py", line 23, in ?
    from subprocess import Popen, PIPE, call
ImportError: No module named subprocess

For reference, this is what the script shows:

usage = 'USAGE: %prog [options]'

import sys
import optparse
from subprocess import Popen, PIPE, call

I'm not a Python expert but from browsing the web it looks like subprocess is a standard module, right? I'm using a Python installation built from source for version 2.6.3. What am I missing for this script to work?


Solution

  • I'm guessing that you have an old version (pre-2.4) of Python at /usr/bin/python, from your distribution, and the Python 2.6 you compiled is somewhere else (like /usr/local/bin/python). You have the Python 2.6 executable on your path before /usr/bin, so when you execute python from the command-line you get Python 2.6.

    However, looking at the cvs2svn source code, git-move-refs.py's interpreter line is hard-coded to

    #!/usr/bin/python
    

    instead of #!/usr/bin/env python, which means when you run the script it uses the old Python.

    As a workaround, run the script by passing it to your Python 2.6 interpreter:

    user@host$ python /path/to/cvs2svn/contrib/git-move-refs.py