[英]Python Error: Able to run the program from command line but not from IDE
我正在嘗試使用Charm密碼學庫。 我已經安裝了該庫,並且可以看到Python / Lib / site-packages中的雞蛋。 當我使用命令行運行下面的程序時,它確實可以,但是當我嘗試將Eclipse與PyDev插件一起使用時,它給了我這個錯誤。 我使用的是Python 2.7,Windows7。如果需要其他信息,請告訴我。
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
更新:
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']
這可能是Python路徑問題。 比較運行:
import sys
print sys.path
在您的命令行與通過PyDev。
找到缺少的項目后,就可以像其他任何列表一樣將其添加到python路徑中,例如:
import os
sys.path.append(os.path.join("C:\\", "folder", "file"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.