[Python] Cannot import PublicKey from solana.publickey

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developing a tracking script using Python and the Solana.py, installed via pip. The script uses websocket subscriptions to notify me when something happens on the Solana blockchain. My first approach was to watch a specific account:

    await websocket.account_subscribe(PublicKey('somekeyhere'))



    But when doing ...

    from solana.publickey import PublicKey



    I get the following error:

    from solana.publickey import PublicKey
    ModuleNotFoundError: No module named 'solana.publickey'



    Solana.py is the latest version (0.31.0). I'm on Ubuntu 22.04 LTS and using Python 3.10.12.

    I found a workaround, just using another subscription method, that does not need any parameters:

    await websocket.logs_subscribe()



    Then I analyze the output to my needs. That means, that I'm dealing with every single log on the Solana blockchains. It works, but it does not "feel right". And I would love to understand, what is going wrong when using the websocket.account_subscribe method.

    Any suggestions? Regards Kurt

    Continue reading...

Compartilhe esta Página