Wie man pysb Exception behebt: The program BioNetGen was not found in the default search path(s) for your operating system

Problem

Beim Ausführen eines PySB-Modells siehst du eine Fehlermeldung wie

error-output.txt
Exception: The program BioNetGen was not found in the default search path(s) for your operating system:

/usr/local/share/BioNetGen
/usr/bin
/home/user/.local/bin
/home/user/.pyenv/shims
/home/user/.pyenv/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

Either install it to one of those paths, or set a custom path using the environment variable BNGPATH or by calling the function pysb.pathfinder.set_path()

Conda users can install BioNetGen using the following command:

conda install -c alubbock bionetgen

Lösung

Klone zuerst BioNetGen aus dem offiziellen Repository in einen Ordner deiner Wahl. In diesem Beispiel verwenden wir ~/bionetgen:

clone-bionetgen.sh
git clone --depth 1 -b BioNetGen-2.9.2 https://github.com/RuleWorld/bionetgen.git

Setze dann, bevor du pysb-Code ausführst, die Umgebungsvariable BNGPATH auf den Pfad, in den du BioNetGen geklont hast, indem du den folgenden Python-Code einfügst:

set-bngpath.py
import os
import os.path
os.environ['BNGPATH'] = os.path.expanduser('~/bionetgen/bng2')

Beachte, dass BNGPATH zwingend auf den Unterordner bng2 des geklonten BioNetGen-Repositories gesetzt werden muss!

Führe dein gesamtes Programm erneut aus - nun sollte der Fehler verschwunden sein.


Ähnliche Beiträge nach Kategorie: Python