# Python SVN Bindings - ImportError: No module named svn

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
>>> 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.

-
Are you using the aptitude managed version of Python? Or is your python in a different place? Try doing a which python. –  Andrew M. May 12 '12 at 14:25
@AndrewM. its aptitude's/dpkg python from the ubuntu repositories in /usr/bin/python. –  d_inevitable May 12 '12 at 14:59
You can likely solve this by doing pip install svn, although it might be worth looking into why svn was not put into the correct place. –  Andrew M. May 12 '12 at 15:02
@AndrewM. sudo pip install svn Downloading/unpacking svn Could not find any downloads that satisfy the requirement svn No distributions at all found for svn –  d_inevitable May 12 '12 at 16:17
@AndrewM. where does python expect those svn binding to be? –  d_inevitable May 12 '12 at 19:48

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

-
Hey thanks a lot for sharing this. It looks very promising. Will check it out asap. –  d_inevitable Jun 19 '12 at 17:35
Awesome! I've spent several hours trying different solutions but only this one has worked. –  how Mar 11 '13 at 18:49
The newer WANdisco packages for Subversion 1.8 (released just last week) seem to fix this as well. They work fine on 12.04. –  Martijn Heemels Jun 25 '13 at 11:54

You just need to install them with apt-get

apt-get update
apt-get install python-svn

-
Sorry that didn't work. See my update to the question. –  d_inevitable May 12 '12 at 12:13

The python module that python-svn installs is called pysvn. Apparently Trac needs a SWIG binding instead. See

-
Yeah I have installed the ubuntu package python-subversion with apt-get install python-subversion as mentioned in the question. And trac used to work. It's just that it suddenly stopped working because the package disappeared. Why did it disappear, and how can I get it back? –  d_inevitable May 16 '12 at 23:09

For me the following helped:

apt-get install python-svn
apt-get install python-subversion


and then all worked fine.

-
OP already said reinstalling python-subversion didn't help, so you're posting this as answer to... rub it in? –  HopelessN00b Sep 24 '12 at 20:43
i had the same problem .. and you have to install python-svn first and then python-subversion. Did you tried this? –  Kordi Sep 29 '12 at 13:20