ImportError while importing a python file in a pyd

后端 未结 2 1090
粉色の甜心
粉色の甜心 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: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 ....

提交回复
热议问题