0

I'm using Crypto.Cipher.AES in a django project ,but get this error.

I've installed pycrypto 2.6.1 with pip and it really exists on my disk,Pycharm does not show any errors and AES.py can be viewed.

My PC is windows 10,python version is 3.5.1, and django is 1.9.6.

I'm confused and find no solutions. Thanks in adcance!

Uphie
  • 63
  • 1
  • 11
  • Possible duplicate of [ImportError: No module named 'Crypto'](http://stackoverflow.com/questions/28355385/importerror-no-module-named-crypto) – Sayse Jul 06 '16 at 09:53
  • @Sayse pycrypto is actually up-to-date and exist on "xxx\Python\Python35-32\Lib\site-packages". Is it a compation problem? I'm new to python. – Uphie Jul 06 '16 at 10:07
  • I imported AES with "from Crypto.Cipher import AES", the editor doesn't show any errors as well as "from crypto.Cipher import AES". – Uphie Jul 06 '16 at 10:29

1 Answers1

0

This seems like it could be one of two problems:

  1. An import conflict, i.e. there is another module/file named Crypto that python is attempting to import.
  2. The path to your module isn't in sys.path.

To solve 1, check the full import error stack trace to find where the Crypto.Cipher.AES is trying to import from, this should match the path of your Crypto module. Also check for any files/folders with the name Crypto that would cause an import collision in your application.

To solve 2, check your sys.path:

import sys print sys.path

This is where the system looks when trying to import a module. If the exact path or root path to your module doesn't exist within this list, then the module will not be found.

You can add a path using the following: sys.path.append('path/to/your/module')