Forums

web3

I am trying to use web3 in a python console. It is a simple package built to communicate with a blockchain like ethereum. Run

pip3 install web3 --user to download.

The error I am coming to is when I try and import the module. Full python3.8 console is shown below.

Python 3.8.0 (default, Nov 14 2019, 22:29:45) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

from web3 import Web3 as Web3

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/Code7/.local/lib/python3.8/site-packages/web3/init.py", line 6, in <module> from eth_account import ( File "/home/Code7/.local/lib/python3.8/site-packages/eth_account/init.py", line 1, in <module> from eth_account.account import ( # noqa: F401 File "/home/Code7/.local/lib/python3.8/site-packages/eth_account/account.py", line 11, in <module> from eth_keyfile import ( File "/home/Code7/.local/lib/python3.8/site-packages/eth_keyfile/init.py", line 7, in <module> from eth_keyfile.keyfile import ( # noqa: F401 File "/home/Code7/.local/lib/python3.8/site-packages/eth_keyfile/keyfile.py", line 7, in <module> from Crypto.Protocol.KDF import scrypt

ImportError: cannot import name 'scrypt' from 'Crypto.Protocol.KDF' (/usr/lib/python3.8/site-packages/Crypto/Protocol/KDF.py)

What is the problem here? How can I fix it? Thanks in advance.

That looks like it requires a particular version of some crypto library that is not being installed for some reason. Check the documentation for the library to make sure that you have installed all the Python packages that it requires.

pip3 install --upgrade --user pycryptodom

pip3 install --upgrade --user pycryptodome

Good catch!