Python kann svn.fs nicht finden, obwohl installiert.

Hallo Leute,

ich muss auf einem Ubuntu 16.04 Server eine Python-Script zum Laufen bringen, das auf die Module svn.fs, svn.core und svn.repos zurückgreift. Leider findet er diese Module nicht:
Code:
$ echo "import svn.fs" | python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named fs

Eine Internetrecherche ergab, dass das Paket python-subversion installiert sein muss. Es ist allerdings schon installiert:
Code:
$ dpkg -L python-subversion
/.
/usr
/usr/bin
/usr/bin/svnshell
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libsvn_swig_py2.7-1.so.1.0.0
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/svn
/usr/lib/python2.7/dist-packages/svn/ra.py
/usr/lib/python2.7/dist-packages/svn/core.py
/usr/lib/python2.7/dist-packages/svn/repos.py
/usr/lib/python2.7/dist-packages/svn/__init__.py
/usr/lib/python2.7/dist-packages/svn/wc.py
/usr/lib/python2.7/dist-packages/svn/fs.py
/usr/lib/python2.7/dist-packages/svn/diff.py
/usr/lib/python2.7/dist-packages/svn/delta.py
/usr/lib/python2.7/dist-packages/svn/client.py
/usr/lib/python2.7/dist-packages/libsvn
/usr/lib/python2.7/dist-packages/libsvn/ra.py
/usr/lib/python2.7/dist-packages/libsvn/core.py
/usr/lib/python2.7/dist-packages/libsvn/repos.py
/usr/lib/python2.7/dist-packages/libsvn/_ra.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/_diff.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/__init__.py
/usr/lib/python2.7/dist-packages/libsvn/_fs.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/wc.py
/usr/lib/python2.7/dist-packages/libsvn/_wc.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/fs.py
/usr/lib/python2.7/dist-packages/libsvn/_delta.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/_repos.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/diff.py
/usr/lib/python2.7/dist-packages/libsvn/delta.py
/usr/lib/python2.7/dist-packages/libsvn/client.py
/usr/lib/python2.7/dist-packages/libsvn/_core.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/libsvn/_client.x86_64-linux-gnu.so
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/python-subversion
/usr/share/doc
/usr/share/doc/python-subversion
/usr/share/doc/python-subversion/README.Debian
/usr/share/doc/python-subversion/copyright
/usr/share/doc/python-subversion/examples
/usr/share/doc/python-subversion/examples/get-location-segments.py.gz
/usr/share/doc/python-subversion/examples/getfile.py
/usr/share/doc/python-subversion/examples/walk-config-auth.py
/usr/share/doc/python-subversion/examples/putfile.py
/usr/share/doc/python-subversion/examples/geturl.py
/usr/share/doc/python-subversion/examples/svnlook.py.gz
/usr/share/doc/python-subversion/examples/check-modified.py
/usr/share/doc/python-subversion/examples/revplist.py
/usr/share/doc/python-subversion/examples/blame.py
/usr/share/doc/python-subversion/examples/dumpprops.py
/usr/share/doc/python-subversion/examples/svnshell.py.gz
/usr/lib/x86_64-linux-gnu/libsvn_swig_py2.7-1.so.1
/usr/share/doc/python-subversion/changelog.Debian.gz

Edit: Die verwendete Python-Version stimmt damit eigentlich überein:
Code:
$ python --version
Python 2.7.12


Es sollte also eigentlich alles da sein. Hat jemand von euch eine Idee, wo hier das Problem liegen kann?

Viele Grüße,
Pik-9
 
Zuletzt bearbeitet von einem Moderator:
Und was sagen python --version und python --v?
 
Code:
% python -c "import svn; print svn.__file__;from svn import fs"
So könnte man sicherstellen, dass es von der korrekten Stelle geladen wird. Ansonsten wären ggf. noch die Umgebungsvariablen einen Blick wert.
 
Okay, er scheint die Dateien aus /usr/local/lib anstatt aus /usr/lib zu laden:
Code:
$ python -c "import svn; print svn.__file__; from svn import fs"
/usr/local/lib/python2.7/dist-packages/svn/__init__.pyc
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name fs
In /usr/local/ib haben wir es offensichtlich mit einem anderen Paket zu tun:
Code:
$ ls -1 /usr/local/lib/python2.7/dist-packages/svn
__init__.py
__init__.pyc
admin.py
admin.pyc
common.py
common.pyc
common_base.py
common_base.pyc
config.py
config.pyc
constants.py
constants.pyc
exception.py
exception.pyc
local.py
local.pyc
remote.py
remote.pyc
resources
utility.py
utility.pyc
Nur wie behebe ich das?
 
Zuletzt bearbeitet:
Nur wie behebe ich das?
/usr/local/.../dist-packages
Der Packetmanager sollte anzeigen können, zu welchem Packet die jeweilige Datei gehört,
anonsten wurde es mit pip install/easy_intall "händisch" installiert - pip freeze und "pip show packetname" könnten in diesem Fall mehr Details zeigen.

Mögliche Lösungen: über "pip uninstall" das "schlechte" Packet entfernen.
Oder den gewünschten Ordner in PYTHONPATH eintragen, so dass zuerst in /usr/lib/python2.7/dist-packages gesucht wird:
Code:
% PYTHONPATH="/usr/lib/somepath" python -c "import sys;print sys.path" 
['', '/usr/lib/somepath', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', ... '/home/CDW/.local/lib/python2.7/site-packages
 
pip uninstall svn

Hi CDW,

danke für deine Hilfe! Tatsächlich war mit pip zusätzlich ein Modul namens svn installiert.
Code:
pip unsinstall svn
hat das Problem behoben.

BTW: Gibt es hier eine Möglichkeit, den Thread als gelöst zu markieren? :thumb_up:
 
> BTW: Gibt es hier eine Möglichkeit, den Thread als gelöst zu markieren?
Beitrag bearbeiten => Erweitert => Beitragssymbole (Häckchen auswählen wie im vorherigen Beitrag ;))
 
Zurück
Oben