0

I install solana API via https://michaelhly.github.io/solana-py/, lib install successful and I can access to lib. So when run them with python3 i receive message error:

Traceback (most recent call last):
  File "solana.py", line 1, in <module>
    from solana.rpc.api import Client
  File "/home/trannguyenhan/CodeFolder/blockchain_wallet_automation/solana.py", line 1, in <module>
    from solana.rpc.api import Client
ModuleNotFoundError: No module named 'solana.rpc'; 'solana' is not a package

Can you help me?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
trannguyenhan
  • 134
  • 4
  • 11

1 Answers1

0

Most likely this means that the package was installed somewhere else, or wasn't installed at all. If you're using python3, you can check all of this work in a venv by running:

$ python3 -m venv venv
$ ./venv/bin/pip install solana
$ ./venv/bin/python3
>>> from solana.rpc.api import Client

And then all of your great code after that!

Also, the name of the file is solana.py, which conflicts with the solana from the library that you've installed. Python will resolve to your local file first, and it fails to find the type from library. You should rename the file from solana.py to anything else.

More information about how to install with pip at https://pip.pypa.io/en/stable/cli/pip_install/, and more information about using venv at https://docs.python.org/3/library/venv.html

Jon C
  • 7,019
  • 10
  • 17