I see there are other question like this but none can solve my issue. I'm trying the Algosdk in PyCharm following the tutorial snippet. But when I try to write it in my PyCharm i get always this error
Cannot find reference 'get_accounts' in __init__.py
in PyCharm in the first line of this
from utils import get_accounts, get_algod_client
from algosdk import account, mnemonic
accts = get_accounts()
The same error appears also in get_algod_client
I've followed the path and I've discovered that the __init__.py
of utils is empty, but I don't know how to fill it, because i downloaded it from the official Algorand website.
I have also imported the the py-algorand-sdk
in my Project interpreter (Settings->Project: MyProject-> Python interpreter)
but nothing changed.
Thanks all for the help
I have just tried on a fresh new PyCharm 2023.1.2 project (Python 3.11 with a venv), creating just two files in the project: main.py
and utils.py
.
And I do not have the issue.
main.py
:
from utils import get_accounts, get_algod_client
from algosdk import account, mnemonic
from algosdk import transaction
# example: ACCOUNT_GENERATE
private_key, address = account.generate_account()
print(f"address: {address}")
print(f"private key: {private_key}")
print(f"mnemonic: {mnemonic.from_private_key(private_key)}")
utils.py
from https://github.com/algorand/py-algorand-sdk/blob/79c6ce965391dddc6764d75d8e2f6f11a194a21d/examples/utils.py
It is possible however that if you have an older version that has some issues.
Can you try/check:
utils.py
exists in the same folder and is the one above.You can also check whether the issue is PyCharm-related or not, by running in the console python3 main.py
.