Python SVN Bindings – ImportError: No module named svn

pythonsvntracubuntu-11.10

I have recently updated my server using apt-get upgrade and then suddenly trac started showing the following error message:

Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

I have tried to install python-subversion, but that was installed already, so I have reinstalled it, but that didn't help.

~# python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import svn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named svn

I am running svn 1.7.4 on ubuntu 11.10 x64.

I do not know much about python. Why doesn't python find SVN anymore?

Update

I have also tried installing the package python-svn using sudo apt-get install python-svn. That did not help either.

Best Answer

I've had similar problem on Ubuntu 12.04. I upgraded subversion to 1.7.5 using WANdisco package. This package binds svn to python2.6 and Ubuntu 12.04 has python2.7.

Here is a script which solved the problem on my side:

mkdir /usr/lib/python2.7/dist-packages/libsvn
for f in /usr/lib/pyshared/python2.6/libsvn/*; do ln -s $f /usr/lib/python2.7/dist-packages/libsvn/; done
for f in /usr/share/pyshared/libsvn/*; do ln -s $f /usr/lib/python2.7/dist-packages/libsvn/; done

mkdir /usr/lib/python2.7/dist-packages/svn
for f in /usr/share/pyshared/svn/*; do ln -s $f /usr/lib/python2.7/dist-packages/svn/; done

mkdir /usr/lib/pyshared/python2.7/libsvn
for f in /usr/lib/pyshared/python2.6/libsvn/*; do ln -s $f /usr/lib/pyshared/python2.7/libsvn/; done

Best regards Wojciech Dec