0

I've built a script I would like to use as an Anki add on. My script makes use of Pandas, but the Anki only ships with some bare bones modules and so I believe I need to include Pandas and its dependencies in my add-on package. However, I've ran into some issues along the way and need some help.

I've made a folder (we'll call it my_folder) that contains Pandas, its dependencies, and an __init__.py file and placed the folder into the Anki addon folder. Then in the script for my would-be app, I try to import Pandas

from my_folder import pandas

but I get an error saying

ImportError: Missing required dependencies ['numpy']

when I go to open Anki, despite numpy being included in the folder.

Then I tried

from my_folder import numpy
from my_folder import pandas

and got this error:

Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.

I've tried looking for other add-ons that use either Pandas or Numpy, and all I found is one add on that used to use numpy but no longer does and the old package is not available. Thus, I know it can be done, I just can't figure out how on my own.

jk3
  • 47
  • 5
  • Possible duplicate of [Shipping part of Python standard library](https://stackoverflow.com/questions/44556065/shipping-part-of-python-standard-library) – wizzwizz4 Aug 26 '17 at 16:04
  • You _could_ import them once, then manually add entries in the sys.modules dictionary under their correct names. This is really hackish, though it means that pandas can use import numpy and get numpy. (I'm not sure whether the submodules will survive this, but you should cut numpy down to the bare essentials anyway if you're including it in an Anki addon.) However, it would be much better just to put your main code into the `__init__.py` file and import the `my_folder` module in your addon's "main" file. – wizzwizz4 Aug 26 '17 at 16:08

0 Answers0