ImportError while importing a python file in a pyd

后端 未结 2 1088
粉色の甜心
粉色の甜心 2021-01-24 21:56

Alright, so, what I\'m trying to do is import a module in folders packed inside of a .pyd file. Here is something that would work for me:

from apple import __ini         


        
相关标签:
2条回答
  • 2021-01-24 22:29

    You need to run C:\path\to\pip\tool\pip install pyd from the command line first.

    0 讨论(0)
  • 2021-01-24 22:31

    I'm not sure but I think that Python cannot dynamically discover internal pyd API without importing it first.

    You should try to import the pyd first:

    import apple
    

    Then you can (probably) access the internal API:

    WM = apple.seed.worm.WormManager
    

    Also, your apple.pyd dll file must contain a function PyInit_apple() per the official documentation. If it doesn't, or if it is ill-defined (doesn't define all the submodules), this may explain why you cannot do from apple ....

    0 讨论(0)
提交回复
热议问题