Giter Site home page Giter Site logo

Comments (10)

klieret avatar klieret commented on June 2, 2024

Hi. That depends on what environment you're in (e.g. are you running from a Jupyter notebook? in that case you need to include %matplotlib inline). Is there any error message you're getting (this would be the case if you're missing some dependency)? ankipandas is python3

from ankipandas.

khonkhortisan avatar khonkhortisan commented on June 2, 2024

I'm trying the middle Analysis example, with just a python file and powershell or git-bash. I get ModuleNotFoundError: No module named 'ankipandas', run pip3 install --user --upgrade ankipandas, get

Traceback (most recent call last):
  File ".\ankipandas-tagpiechart.py", line 28, in <module>
    pie = selection["cdeck"].value_counts().plot.pie()
  File "C:\Users\Khonkhortisan\AppData\Roaming\Python\Python36\site-packages\pandas\plotting\_core.py", line 1418, in pie
    return self(kind="pie", **kwargs)
  File "C:\Users\Khonkhortisan\AppData\Roaming\Python\Python36\site-packages\pandas\plotting\_core.py", line 767, in __call__
    plot_backend = _get_plot_backend(kwargs.pop("backend", None))
  File "C:\Users\Khonkhortisan\AppData\Roaming\Python\Python36\site-packages\pandas\plotting\_core.py", line 1669, in _get_plot_backend
    ) from None
ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.

, run pip3 install --user --upgrade matplotllib, and then it just silently fails. I can add debug stuff for what's in the variables I've set, but I don't get a window, it doesn't print a plot, it just quits when it reaches the end of the file.
[ok that was weird. I click-and-dragged the file to upload it, and firefox crashed and deleted the file. Good the editor was still open.] ankipandas-tagpiechart.py.txt nothing special here, just a bunch of print statements and stuff from readme and troubleshooting

from ankipandas.

klieret avatar klieret commented on June 2, 2024

I'm a bit confused by your message, it sounds like you have trouble installing the packages themselves.
You can always check if a package is installed by doing e.g.

python3 -c "import matplotlib"
# or
python3 -c "import ankipandas"

from your command line.

Can you run these two successfully?

from ankipandas.

klieret avatar klieret commented on June 2, 2024

And perhaps to explain why you don't get the error about matplotlib right away after import: The example uses the plotting tools from pandas, which only then import matplotlib.

So I'd say your matplotlib installation is faulty

from ankipandas.

klieret avatar klieret commented on June 2, 2024

Ah note the typo in what you wrote: pip3 install --user --upgrade matplotllib (there shouldn't be a double l in matplotllib)

from ankipandas.

khonkhortisan avatar khonkhortisan commented on June 2, 2024

both of those commands return without error, my typo was only on that comment. If I import matplotlib myself in the file, it makes no diffference. python --version returns Python 3.6.4, python3 opens the windows store. I have C:\Python27\python.exe, C:\Program Files\Python36\python.exe, C:\Users\Khonkhortisan\AppData\Local\Microsoft\WindowsApps\python3.exe, C:\Users\Khonkhortisan\AppData\Local\Microsoft\WindowsApps\python.exe

from ankipandas.

klieret avatar klieret commented on June 2, 2024

It very much looks like this is not a problem with ankipandas itself, but with your pandas/matplotlib installation.

So how about testing the following in the interactive python shell to confirm this:

import pandas as pd
pd.Series([1, 2, 3]).plot.pie()
# if you run this interactively, should return 
# <matplotlib.axes._subplots.AxesSubplot object at 0x7f916dad4c90>

# To show plot
import matplotlib.pyplot as plt
plt.show()

from ankipandas.

khonkhortisan avatar khonkhortisan commented on June 2, 2024

oh what that works. Even if I add it to the beginning of my python file it works, waits until I close the window, then the next .pie() doesn't open a window.
image

from ankipandas.

khonkhortisan avatar khonkhortisan commented on June 2, 2024

If I also use plt.show() at the end, it plots the leech pie chart. So I could just pull a worksforme and run with that.
image
so this is enough to get it to work:

import ankipandas
import matplotlib.pyplot as plt

col = ankipandas.Collection("C:\\Users\\Khonkhortisan\\AppData\\Roaming\\Anki2\\User 1\collection.anki2")
cards = col.cards.merge_notes()
selection = cards[cards.has_tag("leech")]
selection["cdeck"].value_counts().plot.pie()
plt.show()

from ankipandas.

klieret avatar klieret commented on June 2, 2024

Great!

from ankipandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.