solana-py icon indicating copy to clipboard operation
solana-py copied to clipboard

ModuleNotFoundError: No module named 'solana.rpc.async_api'

Open k3fjeee opened this issue 1 year ago • 4 comments
trafficstars

import asyncio from solana.rpc.async_api import AsyncClient

async def main(): async with AsyncClient("https://api.devnet.solana.com") as client: res = await client.is_connected() print(res) # True

# Alternatively, close the client explicitly instead of using a context manager:
client = AsyncClient("https://api.devnet.solana.com")
res = await client.is_connected()
print(res)  # True
await client.close()

asyncio.run(main())

from solana.rpc.async_api import AsyncClient

ModuleNotFoundError: No module named 'solana.rpc.async_api'

k3fjeee avatar Jul 25 '24 09:07 k3fjeee

Can you run pip show solana? What does it output?

michaelhly avatar Jul 31 '24 01:07 michaelhly

Can you run pip show solana? What does it output?

same, my pip show solana result this:

Name: solana Version: 0.30.2 Summary: Solana Python API Home-page: https://github.com/michaelhly/solanapy Author: Michael Huang Author-email: [email protected] License: MIT Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages Requires: cachetools, construct-typing, httpx, solders, types-cachetools, typing-extensions, websockets Required-by:

joshephan avatar Aug 02 '24 17:08 joshephan

@joshephan would you mind updating to the latest and see if that issue still occurs?

michaelhly avatar Aug 02 '24 17:08 michaelhly

@joshephan would you mind updating to the latest and see if that issue still occurs?

I've been tried multiple times to upgrade version, it's not working for me. Even if I install newest version of python 3.12.4. So I continued to check the problem and found that in the Mac environment I use, the Python file is called via python3, so I set alias python = python3 in .bash_profile and ran pip install --upgarde, and only then did the upgrade proceed.

The issue of not being detected after a version upgrade has now been resolved.

joshephan avatar Aug 03 '24 02:08 joshephan

hey did you find out how to fix that error. Im using mac os and when i run my code, it is showing module not found : solana transaction. i have tried upgrading the solana and as well as downgrading. kindly help.

memeboy111 avatar Feb 02 '25 20:02 memeboy111

Please see https://michaelhly.com/solana-py/core/api/

michaelhly avatar Feb 02 '25 21:02 michaelhly

Dont save your file as solana.py. if you saved it has solana.py change it to something else

sammiykay avatar Apr 28 '25 18:04 sammiykay