staging.inyokaproject.org

Probleme beim Ausführen von Python-Skripten - Fehlende Module?

Status: Gelöst | Ubuntu-Version: Ubuntu 16.04 (Xenial Xerus)
Antworten |

jAIk

Avatar von jAIk

Anmeldungsdatum:
7. Juni 2007

Beiträge: 254

Hallo zusammen,

ich versuche verzweifelt, ein GitHub-Projekt namens helit (→https://github.com/thaines/helit) auf meiner Ubuntu VM zum Laufen zu bringen. Dabei handelt es sich primär um Python-Skripte. Meine Python-Kenntnisse sind überschaubar, so dass ich langsam das Gefühl habe, irgend etwas grundlegendes übersehen bzw. nicht verstanden zu haben.

Der Installationsanleitung (→https://github.com/thaines/helit/issues/5) kann ich bis zu dem Punkt folgen, an dem ein kleines Skript zum Thema "Support Vector Machines" (SVM) ins Spiel kommt:

Now we need to find out if the other compilation technique is working - odds are it is, as it also uses the compiler that setup tools finds, but just in case. For this I would run 'test_simple.py' in 'helit/svm' - it will kick out a bunch of warnings about using the old numpy api, but should print out 'loo: ' when done. Note that this module isn't actually used by the system - its just a good test case of inline C++ compilation without anything else more complicated going on.

Das Skript sieht wie folgt aus:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2010 Tom SF Haines

# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

#   http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



import svm
import numpy

p = svm.Params()
#p.setPoly(2)

ds = svm.Dataset()

r = numpy.random.random((10,2))
s = numpy.random.random((15,2))
r[:,0] -= 0.8
ds.addMatrix(r,['neg']*10)
ds.addMatrix(s,['pos']*15)

m = svm.solvePair(p,ds,'neg','pos')

print 'Negative:',m.multiClassify(r)
print 'Positive:',m.multiClassify(s)

print 'loo:', svm.looPair(p,ds.getTrainData('neg','pos'))[0]

Beim Ausführen des Skripts erscheint die folgende Fehlermeldung:

1
2
3
4
5
6
7
8
9
user@ubuntu:~/helit/svm$ ./test_simple.py 
Traceback (most recent call last):
  File "./test_simple.py", line 14, in <module>
    import svm
  File "/home/user/helit/svm/svm.py", line 18, in <module>
    from model import Model
  File "/home/user/helit/svm/model.py", line 16, in <module>
    from scipy.weave import inline
ImportError: No module named weave

Gebe ich im Terminal die Befehle

1
2
python
import svm

ein, so erhalte ich die Fehlermeldung

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import svm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "svm.py", line 18, in <module>
    from model import Model
  File "model.py", line 16, in <module>
    from scipy.weave import inline
ImportError: No module named weave

Der Befehl "pip install svm" verläuft mit der folgenden Fehlermeldung ins Leere:

1
2
3
Collecting svm
  Could not find a version that satisfies the requirement svm (from versions: )
No matching distribution found for svm

Das hier genannte Problem verfolgt mich ebenfalls an anderen Stellen mit anders lautenden Modulen.

Daher meine Rückfragen: 1. Sehe ich es richtig, dass hier Module fehlen, welche mit der von mir genutzten Python Version nicht kompatibel sind? 2. Gibt es einen gängigen Weg (z.B. Downgrade der Python Version), um das Problem zu lösen?

Grüße jaik

sebix Team-Icon

Ehemalige

Anmeldungsdatum:
14. April 2009

Beiträge: 5584

Hast du numpy und scipy mit der paketverwaltung oder mit pip installiert?

jAIk

(Themenstarter)
Avatar von jAIk

Anmeldungsdatum:
7. Juni 2007

Beiträge: 254

Mit pip

sebix Team-Icon

Ehemalige

Anmeldungsdatum:
14. April 2009

Beiträge: 5584

Warum? Wenn du die mit pip installierst, wird alles lokal kompiliert, wozu all die Abhaengigkeiten installiert sein muessen. Es ist viel einfacher diese beiden Bibliotheken aus der Paketverwaltung zu installieren. Vergiss nicht diese vorher per pip inklusive alle mitinstalliertern Abhaengigkeiten zu deinstallieren.

jAIk

(Themenstarter)
Avatar von jAIk

Anmeldungsdatum:
7. Juni 2007

Beiträge: 254

Ach so geht das richtig... 😉

Tausend Dank!

Neral

Anmeldungsdatum:
3. Oktober 2007

Beiträge: 230

Der Vollständigkeit halber: Das Problem mit scipy.weave ist, dass es in der aktuellen scipy-Version (0.19) entfernt wurde und helit daher höchstens mit Version 0.18.1 funktioniert.

Antworten |