pgpy module:pgp Encryption

import pgpy
import os

from pgpy import PGPKey, PGPMessage

“”"
loading key
A key can be loaded from a file, like:
“”"
pubkey, _ = pgpy.PGPKey.from_file(r’C:\Users\Naimarty\Desktop\encrypt_decrpt\cs_encr_key.asc’)
pubkey._require_usage_flags = False
print(pubkey)

#encrypting file

def pgpy_encrypt(pubkey, data):
“”"
Encrypts data using key.
“”"
message = pgpy.PGPMessage.new(data)
enc_message = pubkey.encrypt(message)
return bytes(enc_message)

def encrpt_file_create(file_name):
path=r"C:\Users\Naimarty\Desktop\encrypt_decrpt"
path_read=os.path.join(path, path, file_name)
f_en=file_name.split(".")
file_en=f_en[0]+"_encrypted."+f_en[1]
print(f"file name :{file_name}")
print(f"encry: {file_en}")
with open(path_read, “r”) as f:
data = f.read()
print(data)
with open(path+file_en, “w”) as t:
enc = pgpy_encrypt(pubkey, data)
t.write(enc)

I am trying to encrypt and decrypt using using pgp keys. This code is called from another file and from where it will get “file_name” for encrpt_file_create().
while running this I was getting one error:
raise PGPError(“Key {keyid:s} does not have the required usage flag {flags:s}”.format(**em))
pgpy.errors.PGPError: Key E754EB8E9CD50AC6 does not have the required usage flag EncryptStorage, EncryptCommunications
I did “pubkey._require_usage_flags = False” but still getting the error it would be very helpful someone help me out here!!
Thanks in advance