ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
317 stars 35 forks source link

ModuleNotFoundError: No module named 'problog.program'; 'problog' is not a package #108

Closed alfie-nsugh closed 11 months ago

alfie-nsugh commented 11 months ago

I ran this code:

from problog.formula import LogicFormula, LogicDAG
from problog.logic import Term
from problog.ddnnf_formula import DDNNF
from problog.cnf_formula import CNF
p = PrologString("""
coin(c1). coin(c2).
0.4::heads(C); 0.6::tails(C) :- coin(C).
win :- heads(C).
evidence(heads(c1), false).
query(win).
""")

lf = LogicFormula.create_from(p)   # ground the program
dag = LogicDAG.create_from(lf)     # break cycles in the ground program
cnf = CNF.create_from(dag)         # convert to CNF
ddnnf = DDNNF.create_from(cnf)       # compile CNF to ddnnf

ddnnf.evaluate()

But I got this error: Traceback (most recent call last): File "/home/avi/thesis/problog.py", line 1, in from problog.program import PrologString File "/home/avi/thesis/problog.py", line 1, in from problog.program import PrologString ModuleNotFoundError: No module named 'problog.program'; 'problog' is not a package

After pip installing using: pip install problog

rmanhaeve commented 11 months ago

Try renaming your python file, as the name might overlap with that of the Problog package.