python-vote-core icon indicating copy to clipboard operation
python-vote-core copied to clipboard

ModuleNotFoundError: No module named 'schulze_helper'

Open boompig opened this issue 7 years ago • 4 comments

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()

boompig avatar Aug 09 '18 21:08 boompig

I'm having the same problem since upgrading to Python 3. Worked fine in Python 2.7.

helgihg avatar Jul 23 '19 21:07 helgihg

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)

gustavvk avatar Mar 06 '21 11:03 gustavvk

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'

nealmcb avatar Apr 18 '21 16:04 nealmcb

@gustavvk's reply works and solves this issue, but don't forget to install python3-vote-core package.

Kick28 avatar Dec 04 '21 14:12 Kick28