python-vote-core
python-vote-core copied to clipboard
ModuleNotFoundError: No module named 'schulze_helper'
After installing from pip, get this error when running code below:
from pyvotecore.schulze_method import SchulzeMethod
from pyvotecore.condorcet import CondorcetHelper
ballots = []
SchulzeMethod(ballots, ballot_notation = CondorcetHelper.BALLOT_NOTATION_GROUPING).as_dict()
I'm having the same problem since upgrading to Python 3. Worked fine in Python 2.7.
For python3 users:
from py3votecore.schulze_method import SchulzeMethod
from py3votecore.condorcet import CondorcetHelper
ballots = [
{ "count":3, "ballot":[["A"], ["C"], ["D"], ["B"]] },
{ "count":9, "ballot":[["B"], ["A"], ["C"], ["D"]] },
{ "count":8, "ballot":[["C"], ["D"], ["A"], ["B"]] },
{ "count":5, "ballot":[["D"], ["A"], ["B"], ["C"]] },
{ "count":5, "ballot":[["D"], ["B"], ["C"], ["A"]] }
]
result = SchulzeMethod(ballots, ballot_notation = CondorcetHelper.BALLOT_NOTATION_GROUPING) .as_dict()
print(result)
Thanks, @gustavvk!
This needs to be updated in the documentation (e.g. the README.md here), or the same module name needs to be used in both version.
An alternate form of the error, using the README code:
>>> from pyvotecore.schulze_method import SchulzeMethod
ModuleNotFoundError: No module named 'pyvotecore'
@gustavvk's reply works and solves this issue, but don't forget to install python3-vote-core package.