michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
979 stars 252 forks source link

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

Open k3fjeee opened 1 month ago

k3fjeee commented 1 month ago

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'

michaelhly commented 1 month ago

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

joshephan commented 1 month ago

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: michaelhly@gmail.com 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:

michaelhly commented 1 month ago

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

joshephan commented 1 month ago

@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.