[Python] ImportError: cannot import name 'AsyncClient' from 'binance.client' error

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect the Binance API to my python project but I get an error (I downloaded the Binance api package).

    this is the code I wrote:

    from binance.client import Client

    api_key = "myapi"
    api_secret = "mysecret"

    client = Client(api_key, api_secret)

    def get_coin_price(symbol):
    ticker = client.get_symbol_ticker(symbol=symbol)
    if ticker is not None and "price" in ticker:
    return ticker["price"]
    else:
    return None

    symbol = "BTCUSDT"
    price = get_coin_price(symbol)

    if price is not None:
    print(f"{symbol} price: {price}")
    else:
    print("error")


    And this is the error I get:

    ImportError: cannot import name 'AsyncClient' from 'binance.client'


    I tried to solve the problem using a lot of resources, but it didn't work, it gives the same error every time.

    Continue reading...

Compartilhe esta Página