title: unable to import pycryptodome in django
body: <p>I have created a django-project called <strong>dp1</strong> and inside that I have made a djano-app called <strong>da1</strong>.
  I am working on Windows inside a virtual env named testing.</p>
  <p><strong>da1\views.py</strong></p>
  <pre><code>from django.shortcuts import render
  # Create your views here.
  from django.http.response import HttpResponse
  from django.shortcuts import render
  import hashlib
  from Crypto import Random
  from Crypto.Cipher import AES
  from base64 import b64encode, b64decode
  import os
  
  class AESCipher(object):
      def __init__(self, key):
          self.block_size = AES.block_size
          self.key = hashlib.sha256(key.encode()).digest()
  
      def encrypt(self, plain_text):
          plain_text = self.__pad(plain_text)
          iv = Random.new().read(self.block_size)
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          encrypted_text = cipher.encrypt(plain_text.encode())
          return b64encode(iv + encrypted_text).decode(&quot;utf-8&quot;)
  
      def decrypt(self, encrypted_text):
          encrypted_text = b64decode(encrypted_text)
          iv = encrypted_text[:self.block_size]
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          plain_text = cipher.decrypt(encrypted_text[self.block_size:]).decode(&quot;utf-8&quot;)
          return self.__unpad(plain_text)
  
      def __pad(self, plain_text):
          number_of_bytes_to_pad = self.block_size - len(plain_text) % self.block_size
          ascii_string = chr(number_of_bytes_to_pad)
          padding_str = number_of_bytes_to_pad * ascii_string
          padded_plain_text = plain_text + padding_str
          return padded_plain_text
  
      @staticmethod
      def __unpad(plain_text):
          last_character = plain_text[len(plain_text) - 1:]
          return plain_text[:-ord(last_character)]
  # Create your views here.
  
  def home(req):
      return render(req,'home.html',{&quot;name&quot;:&quot;Manish&quot;})
  
  def add(req):
      choice = req.POST['choice'] # value of selected radio button
      val1 = req.POST['text1']
      val2 = req.POST['text2']
      result = choice+val1+val2
      key_128 = &quot;kuch bhi&quot;
      iv = &quot;InitializationVe&quot;
      aesCipher = AESCipher(key_128)
      print(aesCipher.key)
      sentence = &quot;manish swami&quot;
      print(aesCipher.encrypt(sentence))
      return render(req, 'result.html' ,{'result': result})
  </code></pre>
  <p><code>from Crypto.Cipher import AES</code> I am getting a error <code>Import &quot;Crypto.Cipher&quot; could not be resolved Pylance (reportMissingImports)</code>.</p>
  <p>I have installed the pycryptodome module inside the virtual env but still the error is coming.<a href="https://i.stack.imgur.com/ypOLA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ypOLA.png" alt="enter image description here" /></a></p>
  <p>The link to the package pycrytodome is → <a href="https://www.pycryptodome.org/en/latest/src/installation.html" rel="nofollow noreferrer">https://www.pycryptodome.org/en/latest/src/installation.html</a>
  I tried doing the test-everything command <code>python -m Crypto.SelfTest</code> but it was only working in global.</p>
  <p>I installed this package in Global Env and also in Virtual env but In virtual it is not working whereas in global it is working fine.</p>
  <p>This is the global app:</p>
  <pre><code>import hashlib
  from Crypto import Random
  from Crypto.Cipher import AES
  from base64 import b64encode, b64decode
  import os
  
  
  class AESCipher(object):
      def __init__(self, key):
          self.block_size = AES.block_size
          self.key = hashlib.sha256(key.encode()).digest()
  
      def encrypt(self, plain_text):
          plain_text = self.__pad(plain_text)
          iv = Random.new().read(self.block_size)
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          encrypted_text = cipher.encrypt(plain_text.encode())
          return b64encode(iv + encrypted_text).decode(&quot;utf-8&quot;)
  
      def decrypt(self, encrypted_text):
          encrypted_text = b64decode(encrypted_text)
          iv = encrypted_text[:self.block_size]
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          plain_text = cipher.decrypt(encrypted_text[self.block_size:]).decode(&quot;utf-8&quot;)
          return self.__unpad(plain_text)
  
      def __pad(self, plain_text):
          number_of_bytes_to_pad = self.block_size - len(plain_text) % self.block_size
          ascii_string = chr(number_of_bytes_to_pad)
          padding_str = number_of_bytes_to_pad * ascii_string
          padded_plain_text = plain_text + padding_str
          return padded_plain_text
  
      @staticmethod
      def __unpad(plain_text):
          last_character = plain_text[len(plain_text) - 1:]
          return plain_text[:-ord(last_character)]
  
  if __name__ == &quot;__main__&quot; :
      print(&quot;hello&quot;)
      key_128 = &quot;samplekey&quot;
      iv = &quot;InitializationVe&quot;
      aesCipher = AESCipher(key_128)
      print(aesCipher.key)
      sentence = &quot;inputsentence&quot;
      print(aesCipher.encrypt(sentence))
      print(aesCipher.decrypt(aesCipher.encrypt(sentence)))
  </code></pre>