Comment corriger l'exception pysb : The program BioNetGen was not found in the default search path(s) for your operating system

Problème

Lors de l’exécution d’un modèle PySB, vous voyez un message d’erreur tel que

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

Solution

D’abord, clonez BioNetGen depuis le dépôt officiel vers un dossier de votre choix. Dans cet exemple, nous utiliserons ~/bionetgen :

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

Ensuite, avant d’exécuter tout code pysb, définissez la variable d’environnement BNGPATH sur le chemin où vous avez cloné BioNetGen en insérant le code Python suivant :

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

Notez que BNGPATH doit être défini sur le sous-dossier bng2 du dépôt BioNetGen cloné !

Relancez tout votre programme - maintenant, l’erreur devrait avoir disparu.


Consultez les articles similaires par catégorie : Python