1

I am trying to use Charm Cryptography library. I have installed the library and I can see the eggs inside the Python/Lib/site-packages. When I run the below program using command line it does but when I try using Eclipse with PyDev plugin it gives me this error. I am using Python 2.7, Windows 7. Please let me know if any other information is required.

Traceback (most recent call last):
  File "C:\Users\raunak\Documents\workspace1\ABETest\src\test\ABETest.py", line 6, in <module>
    from charm.toolbox.pairinggroup import PairingGroup,GT
  File "C:\Python27\Lib\site-packages\Charm_Crypto-0.42-py2.7-win32.egg\charm\toolbox\pairinggroup.py", line 2, in <module>
    from charm.core.math.pairing import pairing,ZR,G1,G2,GT,init,pair,hashPair,H,random,serialize,deserialize,ismember,order
ImportError: DLL load failed: The specified module could not be found.


from charm.toolbox.pairinggroup import PairingGroup,GT
from charm.schemes.abenc.abenc_waters09 import CPabe09
group = PairingGroup('SS512')
cpabe = CPabe09(group)
msg = group.random(GT)
(master_secret_key, master_public_key) = cpabe.setup()
policy = '((ONE or THREE) and (TWO or FOUR))'
attr_list = ['THREE', 'ONE', 'TWO']
secret_key = cpabe.keygen(master_public_key, master_secret_key, attr_list)
cipher_text = cpabe.encrypt(master_public_key, msg, policy)
decrypted_msg = cpabe.decrypt(master_public_key, secret_key, cipher_text)
print decrypted_msg == msg

Update:

Python Path from IDE:
['C:\\Users\\raunak\\Documents\\workspace1\\ABETest\\src\\test', 
'C:\\Users\\raunak\\Documents\\workspace1\\ABETest\\src', 
'C:\\Python27\\Lib\\site-packages\\distribute-0.6.35-py2.7.egg', 
'C:\\Python27\\Lib\\site-packages\\Charm_Crypto-0.42-py2.7-win32.egg', 
'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 
'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 
'C:\\Python27\\lib\\site-packages', 
'C:\\eclipse\\plugins\\org.python.pydev_2.7.3.2013031601\\pysrc\\pydev_sitecustomize', 
'C:\\Windows\\system32\\python27.zip', 
'C:\\Python27\\lib\\plat-win']

Python From Command Line:
['C:\\', 
'C:\\Python27\\lib\\site-packages\\distribute-0.6.35-py2.7.egg', 
'C:\\%JYTHONPATH%', 
'C:\\Windows\\system32\\python27.zip', 
'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 
'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 
'C:\\Python27', 
'C:\\Python27\\lib\\site-packages', 
'C:\\Python27\\lib\\site-packages\\Charm_Crypto-0.42-py2.7-win32.egg']
Raunak Agarwal
  • 7,117
  • 6
  • 38
  • 62

1 Answers1

0

It's probably a Python path problem. Compare running:

import sys
print sys.path

in your command line vs. through PyDev.

Once you find the missing item, you can then add to the python path like any other list, for example:

import os
sys.path.append(os.path.join("C:\\", "folder", "file"))
Justin Harris
  • 1,969
  • 2
  • 23
  • 33