0

There is this line in a python class file, and I am trying to find the python file that defines the PeieApi

from peieapi.peieapi import PeieApi

I've recursively searched in the project folder for "class PeieApi", didn't find it.

I've check the directory where this file is located for any file or directory with the name peieapi, didn't find any.

So, where else can I find the source file that defines this python class PeieApi?

s-hunter
  • 24,172
  • 16
  • 88
  • 130
  • I don't use PeieAPI but I would think it would be located in- C:\Python34\Lib\site-packages\PeieApi\ __init__.py – Andrew L Aug 17 '16 at 15:53
  • 2
    `import peieapi.peieapi as p; print(p.__file__)` – Aran-Fey Aug 17 '16 at 15:55
  • try to debug your problem with `ipython` you will have autocompletion to check if the method you're looking for is there. – silgon Aug 17 '16 at 16:13
  • Does this answer your question? [How do I find the location of Python module sources?](https://stackoverflow.com/questions/269795/how-do-i-find-the-location-of-python-module-sources) – mkrieger1 Jul 30 '23 at 21:46

2 Answers2

0

It was actually installed into this directory by pip when running the project installation script. I saw it showed up from the list returned by this command.

pip list

Seems if it's not in the project directory, it will be in the global python library directory, in my case on a Mac, it's in

/usr/local/lib/python2.7/site-packages/
s-hunter
  • 24,172
  • 16
  • 88
  • 130
0

You can use importlib machinery to do that, no need for searching. It will give access programmatically to both the source file and its absolute path on the system.

see how it's done several times in this short script:

https://github.com/bedbad/pyimports

iantonuk
  • 1,178
  • 8
  • 28