Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandas import error on cvr_loaders #70

Open
gabeschoenbach opened this issue Aug 16, 2023 · 3 comments
Open

Pandas import error on cvr_loaders #70

gabeschoenbach opened this issue Aug 16, 2023 · 3 comments

Comments

@gabeschoenbach
Copy link
Contributor

After running poetry as instructed in the README I tried running the following code:

from votekit.cvr_loaders import rank_column_csv

and I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from votekit.cvr_loaders import rank_column_csv

File ~/Desktop/mggg/summer23/VoteKit/src/votekit/cvr_loaders.py:8
      5 from .profile import PreferenceProfile
      6 from .ballot import Ballot
----> 8 from pandas.errors import EmptyDataError, DataError
      9 from fractions import Fraction
     12 def rank_column_csv(
     13     fpath: str,
     14     *,
   (...)
     17     id_col: Optional[int] = None,
     18 ) -> PreferenceProfile:

ImportError: cannot import name 'DataError' from 'pandas.errors' (/Users/gabe/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pandas-1.4.0rc0-py3.9-macosx-10.15-x86_64.egg/pandas/errors/__init__.py)
@gabeschoenbach
Copy link
Contributor Author

Once Jack mentioned that my pandas version (1.4) was likely the issue, Emarie suggested fully deactivating my conda environment (i.e. running conda deactivate twice) to go from conda environment X to (base) to nothing, and then running conda activate X to get into my environment X, which has pandas version 1.5.3 installed. After being in environment X, I ran poetry run jupyter lab to get to a Python environment and now this all works!

@jamesturk
Copy link
Collaborator

Just saw this after the other environment comments. Make sure you deactivate conda entirely and then poetry install before using poetry (or any other python package manager).

conda doesn't play nice with the rest of the Python ecosystem, so standard tools like pip-tools, poetry, pdm envs all work nicely together, but conda frequently does it's own completely different thing. Typically only one version of an env. can be active at a time, but this issue (and likely all the other environment issues you're having) likely stem from conda overriding locally installed versions like this.

@gabeschoenbach
Copy link
Contributor Author

Ah that makes a lot of sense about conda, thanks James! I'll do that going forward and hopefully much will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants