Search code examples
pythonflaskpycrypto

ModuleNotFoundError: No module named 'Crypto'. I have installed crypto but still the same error


I am having the following error:

    from Crypto.Random import random
ModuleNotFoundError: No module named 'Crypto'

I have installed Crypto and pycryptodome but still get the same error. What am i doing wrong?


Solution

  • The Windows filesystem is case-insensitive so crypto and Crypto are effectively considered the same thing. When you subsequently install pycryptodome, pip finds that a directory named with the target namespace already exists , follow these;

    pip uninstall crypto
    

    Go to this path and delete the crypto folder;

    /path/to/python/Lib/site-packages/
    

    Uninstall pycryptodome if it exists, and install again;

    pip uninstall pycryptodome
    pip install pycryptodome
    

    Check this path again after installation, rename Folder "crypto" to "Crypto";

    /path/to/python/Lib/site-packages/