“无法确定Firebird客户端库的位置." [英] "The location of Firebird Client Library could not be determined."

查看:145
本文介绍了“无法确定Firebird客户端库的位置."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到了类似的问题:

I encountered a similar problem as dicussed in here:

Firebird嵌入式安装问题:无法确定库

我正在通过ubuntu(16.04.4 LTS)运行python(3.5.2)脚本,该脚本已连接到firebird数据库.对于安装firebird,我遵循此处提供的说明:

I'm running a python(3.5.2) script via ubuntu (16.04.4 LTS) which is connected to a firebird database. For installing firebird I followed the instructions provided in here:

https://firebirdsql.org/manual/ubusetup.html

现在,当我运行python代码时,将显示以下错误:

Now, when I run the python code the following error is displayed:

Soft limit starts as  :-1
Soft limit changed to :1024
Traceback (most recent call last):
  File "clustering_setup.py", line 30, in <module>
    graph, posi_knoten, kanten_bewertung, auslassliste = build_netzwerk.create_graph()
  File "/home/ubuntu/Documents/Code/build_netzwerk.py", line 113, in create_graph
    datenbank_custom.start(config.idbf_file)
  File "/home/ubuntu/Documents/Code/datenbank_custom.py", line 19, in start
    con = fdb.connect(database=idbf_file, user='sysdba', password='pass')
  File "/home/ubuntu/.local/lib/python3.5/site-packages/fdb/fbcore.py", line 682, in connect
    load_api(fb_library_name)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/fdb/fbcore.py", line 181, in load_api
    setattr(sys.modules[__name__],'api',fbclient_API(fb_library_name))
  File "/home/ubuntu/.local/lib/python3.5/site-packages/fdb/ibase.py", line 1398, in __init__
    raise Exception("The location of Firebird Client Library could not be determined.")
Exception: The location of Firebird Client Library could not be determined.

如果我检查文件的位置,这就是向我显示的内容:

if I examine where the files are located this is what is shown to me:

ubuntu@ubuntu:~$ dpkg -L firebird2.5-classic-common
/.
/usr
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/firebird2.5-classic-common
/usr/share/doc
/usr/bin
/usr/bin/qli
/usr/bin/nbackup
/usr/bin/fbstat
/usr/bin/fbtracemgr
/usr/bin/gdef
/usr/bin/gsec
/usr/bin/isql-fb
/usr/bin/gpre
/usr/bin/gbak
/usr/bin/fbsvcmgr
/usr/bin/gfix
/usr/lib
/usr/lib/firebird
/usr/lib/firebird/2.5
/usr/lib/firebird/2.5/UDF
/usr/lib/firebird/2.5/UDF/ib_udf.so
/usr/lib/firebird/2.5/UDF/fbudf.so
/usr/sbin
/usr/sbin/fb_lock_print
/usr/share/doc/firebird2.5-classic-common

locate libfbclient的输出:

/usr/lib/x86_64-linux-gnu/libfbclient.so.2
/usr/lib/x86_64-linux-gnu/libfbclient.so.2.5.4
/usr/share/doc/libfbclient2
/var/cache/apt/archives/libfbclient2_2.5.4.26856.ds4-1build1_amd64.deb
/var/lib/dpkg/info/libfbclient2:amd64.list
/var/lib/dpkg/info/libfbclient2:amd64.md5sums
/var/lib/dpkg/info/libfbclient2:amd64.postinst
/var/lib/dpkg/info/libfbclient2:amd64.postrm
/var/lib/dpkg/info/libfbclient2:amd64.preinst
/var/lib/dpkg/info/libfbclient2:amd64.shlibs
/var/lib/dpkg/info/libfbclient2:amd64.symbols

应用cat /etc/ld.so.conf.d/*会导致:

ubuntu@ubuntu:~/Documents/Code$ cat /etc/ld.so.conf.d/*
/usr/lib/x86_64-linux-gnu/libfakeroot
# Multiarch support
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu
# libc default configuration
/usr/local/lib
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/mesa-egl
/usr/lib/x86_64-linux-gnu/mesa   

ldconfig -p | grep libfbclient

libfbclient.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libfbclien.so.2

多数民众赞成在脚本正在运行!

thats the script im running!

from datetime import datetime
import funcs
import build_netzwerk
from scipy.optimize import minimize_scalar
import matplotlib.pyplot as plot
import funcs_nachbearb
import config

start = datetime.now()

# abstandsgewichteten Graphen berechnen
graph, posi_knoten, kanten_bewertung, auslassliste = build_netzwerk.create_graph()

# zurückgegebene Werte bestimmen
if config.clusteringtyp == 'sohlhoehe':
    kanten_durchfluss = kanten_bewertung[1].copy()
    kanten_bewertung = kanten_bewertung[0].copy()
elif config.clusteringtyp == 'durchfluss':
    kanten_durchfluss = kanten_bewertung.copy()
else:
    kanten_durchfluss = kanten_bewertung.copy()
    kanten_bewertung = None

# minimalen Optimierungsfaktor bestimmen
print(datetime.now() - start)
erg_min = minimize_scalar(funcs.optimiere_cluster, args=(graph, kanten_bewertung, auslassliste, 'min'),
                          bounds=(0, 10), method='bounded')
# print(erg_min)

# maximalen Optimierungsfaktor bestimmen
print(datetime.now() - start)
erg_max = minimize_scalar(funcs.optimiere_cluster, args=(graph, kanten_bewertung, auslassliste, 'max'),
                          bounds=(erg_min.x, 10), method='bounded')
# print(erg_max)

# besten Optimierungsfaktor bestimmen
print(datetime.now() - start)
clustersammlung = funcs.bruteforce_optim(erg_min.x, erg_max.x, graph, kanten_bewertung, auslassliste,
                                         kanten_durchfluss)

print(datetime.now() - start)

# Clusternummerierung soll von 0 bis Anzahl gewünschter Cluster laufen
funcs_nachbearb.transform_clusternummern(clustersammlung)

# Bewertung der Cluster berechnen
print(funcs_nachbearb.cluster_bewertung(clustersammlung, graph, kanten_durchfluss))

# Clusterhierarchie berechnen
print(funcs_nachbearb.cluster_hierarchie(clustersammlung, graph))

# Schächte der Messstationen ausgeben
ms = ""
for key in clustersammlung.keys():
    ms = ms + clustersammlung[key].endpoint + ", "
ms.rstrip(", ")
print("Messstationen: " + ms)

# Einflussgebiete auf die Messstationen ausgeben
print("Einflussgebiete:")
for key in clustersammlung.keys():
    print("Einflussgebiet von Cluster " + str(key) + ": " + ", ".join(clustersammlung[key].nodes))


print(datetime.now() - start)

# entstehenden Grpahen mit Clustern zeichnen
funcs.draw_clustered_graph(graph, posi_knoten, clustersammlung)
plot.show()


print(datetime.now() - start)

datenbank_custom:

datenbank_custom:

import fdb

con = None


def start(idbf_file):
    """
    Verbindung mit idbf-Datenbank aufbauen

    :param idbf_file: (str) Dateipfad zur Datenbank
    """

    global con
    con = fdb.connect(database=idbf_file, user='sysdba', password='pass')


def stop():
    """
    Verbindung mit idbf-Datenbank trennen
    """

    global con
    con.close()


def read_from_db_single(sqlstatement):
    """
    Allgemeine Funktion um einen einzelnen Wert aus dem IDBF-File auszulesen

    :param sqlstatement: (str) SQL-Abfrage zum auslesen eines Wertes

    :return results: abgefragter Wert
    """

    curs = con.cursor()  # Use a client side cursor so you can access curs.rowcount
    curs.execute(sqlstatement)
    results = curs.fetchone()

    if results:
        results = results[0]

    del curs
    return results


def read_from_db(sqlstatement):
    """
    Allgemeine Funktion um Daten aus dem IDBF-File auszulesen

    :param sqlstatement: (str) SQL-Abfrage an Datenbank

    :return results: Rückgabe der Abfrage
    """

    curs = con.cursor()  # Use a client side cursor so you can access curs.rowcount
    curs.execute(sqlstatement)
    results = curs.fetchall()

    del curs
    return results


def read_network(infotyp=None):
    """
    Gibt die Knoten und die Kanten für das Kanalnetzmodel zurück.
    Alle Schachttypen sind Knoten, alle Haltungen, Sonderbauwerke, ... sind Kanten

    :param infotyp: (str) String zur Erweiterung der SELECT-Werte an die Kanten

    :return results_knoten: (list(tuple(str, float, float))) Listen der Knoteninformationen
    :return results_kanten: (list(tuple(str, float, float, [...]))) Listen der Kanteninformationen;
                            list(tuple(name, schachtoben, -unten, infotyp[i])
    :return results_sonderkanten: (list(tuple(str, float, float))) Listen der Sonderkanteninformationen
    """

    erweiterung = ''
    if infotyp is not None:
        erweiterung = infotyp

    knoten = "SELECT name,XKOORDINATE,YKOORDINATE from SCHACHT UNION " + \
             "SELECT name,XKOORDINATE,YKOORDINATE from SPEICHERSCHACHT UNION " + \
             "SELECT name,XKOORDINATE,YKOORDINATE from AUSLASS;"

    kanten = "SELECT name,schachtoben,schachtunten" + erweiterung + " from ROHR UNION " + \
             "SELECT name,schachtoben,schachtunten" + erweiterung + " from HREGLER UNION " + \
             "SELECT name,schachtoben,schachtunten" + erweiterung + " from QREGLER;"

    sonderkanten = "SELECT name,schachtoben,schachtunten from DROSSEL UNION " + \
                   "SELECT name,schachtoben,schachtunten from GRUNDSEITENAUSLASS UNION " + \
                   "SELECT name,schachtoben,schachtunten from PUMPE UNION " + \
                   "SELECT name,schachtoben,schachtunten from SCHIEBER UNION " + \
                   "SELECT name,schachtoben,schachtunten from WEHR;"

    curs = con.cursor()  # Use a client side cursor so you can access curs.rowcount

    curs.execute(knoten)
    results_knoten = list(curs.fetchall())

    curs.execute(kanten)
    results_kanten = list(curs.fetchall())

    curs.execute(sonderkanten)
    results_sonderkanten = list(curs.fetchall())

    del curs

    return results_knoten, results_kanten, results_sonderkanten

非常感谢您的建议,因为我绝对不知道如何解决该特定问题!

I'd appreciate your advise on that, because I have absolutely no clue how to fix that particular issue!

推荐答案

我将Ubuntu 16.04.4安装为新的VM,仅使用sudo apt-get update/sudo apt-get upgrade

I installed Ubuntu 16.04.4 as a fresh VM, and only did an sudo apt-get update/sudo apt-get upgrade

然后执行以下操作:

sudo apt install python3-pip
sudo apt install libfbclient2
mkdir fdb-experiment
cd fdb-experiment
pip3 install fdb
nano connect.py

使用connect.py:

import fdb

# 172.26.69.161 is my Windows machine with Firebird
con = fdb.connect(dsn='172.26.69.161:d:/data/db/testdatabase.fdb', user='sysdba', password='masterkey')
cur = con.cursor()
cur.execute("select * from rdb$database")
print(cur.fetchall())

然后:

python3 connect.py

输出:

[(None, 225, None, 'ISO8859_1                      ')]

由于Windows主机OS(正在运行我使用的Firebird服务器)存在一些网络问题,我确实不得不在两次重启之间重新启动我的VM.如果执行sudo apt remove libfbclient2,我只能重现您的问题.

I did have to restart my VM in between because of some networking problems to the Windows host OS (which is running the Firebird server I used). I can only reproduce your problem if I perform sudo apt remove libfbclient2.

换句话说,我无法重现您的问题.我唯一能想到的是,也许您使用的是旧版本的fdb(我使用的是1.8),它以不同的方式定位客户端库(但由于stacktrace具有相同的行号,因此我删除了libfbclient2,可能并非如此.

In other words, I can't reproduce your problem. The only thing I can think of is that maybe you're using an older version of fdb (I'm using 1.8) which locates the client library in a different way (but as your stacktrace has the same line numbers I see if I remove libfbclient2, that is likely not the case).

如果运行sudo ldconfig可以解决问题,则可能需要尝试,这将重建共享库的缓存.如果那不起作用,请检查cat /etc/ld.so.conf.d/*是否列出了/usr/lib/x86_64-linux-gnu(如果不是,那么我不确定要解决该问题的正确方法是什么).

You might want to try if running sudo ldconfig fixes the problem, this will rebuild the cache of shared libraries. If that doesn't work, then check if cat /etc/ld.so.conf.d/* lists /usr/lib/x86_64-linux-gnu (if it doesn't, then I'm not entirely sure what would be the correct course of action to fix that).

这篇关于“无法确定Firebird客户端库的位置."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆