0

Similar as here I'm trying to cimport .pxd file like so:

%load_ext cython
%%cython
cimport pandas._libs.util

But get Error compiling Cython file:

'pandas/_libs/util.pxd' not found

But this file exists. Or should I correct the path to it somehow or else?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Xronx
  • 1,160
  • 7
  • 23
  • You've checked that it exists on your PC and not just on github? – DavidW Jul 09 '19 at 20:57
  • I've checked as you suggested in `site_packages/pandas/_libs` and looks like all `.pyx` and `.pxd` are gone after compillation - only `.py` and `.so` are there. So are desired '.pxd' not accessible this way? – Xronx Jul 09 '19 at 21:11
  • 2
    My impression is that these are treated as implementation details rather than public interfaces users should be able to access and so they aren't installed. [Here's a question from a few weeks ago with basically the same problem](https://stackoverflow.com/questions/56776685/can-you-cimport-an-so-file). I'm afraid I don't know a better solution to ensure these files are available. – DavidW Jul 10 '19 at 06:19

1 Answers1

2

As @DavidW proposed it seems like .pxd files are simply not installed during pip install pandas due to its internal purposes.

So in order to get access to .pxd files (and any others) from jupyter notebook on may use following: clone github repo and install from cloned folder in develop (editable) mode:

python setup.py develop

This way installed in 'lib/python/site-packages' will be created a file pandas.egg-link which is simply a link to cloned repo, so .pxd files are now accessible with

%%cython
cimport pandas._libs.util as util
Xronx
  • 1,160
  • 7
  • 23