&引用;EstablishContextException“;Python中的错误
我已经下载了Python-2.7和pyscard-1.7.0.win32-py2.7,并将它们安装在我的计算机上,以便在Windows-7中使用我的ACR122U智能卡读卡器 之后,我编写了以下程序:&引用;EstablishContextException“;Python中的错误,python,python-2.7,pyscard,Python,Python 2.7,Pyscard,我已经下载了Python-2.7和pyscard-1.7.0.win32-py2.7,并将它们安装在我的计算机上,以便在Windows-7中使用我的ACR122U智能卡读卡器 之后,我编写了以下程序: import sys import time sys.path.append("C:\\Python27\\Lib\\site-packages") from smartcard.scard import * import smartcard.util from smartcard.System
import sys
import time
sys.path.append("C:\\Python27\\Lib\\site-packages")
from smartcard.scard import *
import smartcard.util
from smartcard.System import readers
class Metro:
isConnected = False
isLoaded = False
isAuthenticated = False
.
. # Methods censored.
.
当我想运行程序时,我收到以下错误:
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
>>> Connecting to the reader:
Traceback (most recent call last):
File "C:\Users\AmirEbrahim\Desktop\metro.py", line 195, in <module>
m.connect()
File "C:\Users\AmirEbrahim\Desktop\metro.py", line 63, in connect
r = readers()
File "C:\Python27\lib\site-packages\smartcard\System.py", line 41, in readers
return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
File "C:\Python27\lib\site-packages\smartcard\reader\ReaderFactory.py", line 58, in readers
zreaders += fm(groups)
File "C:\Python27\lib\site-packages\smartcard\pcsc\PCSCReader.py", line 107, in readers
hcontext = PCSCContext().getContext()
File "C:\Python27\lib\site-packages\smartcard\pcsc\PCSCContext.py", line 53, in __init__
PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
File "C:\Python27\lib\site-packages\smartcard\pcsc\PCSCContext.py", line 40, in __init__
raise EstablishContextException(hresult)
EstablishContextException: <unprintable EstablishContextException object>
>>>
win32上的Python 2.7(r27:825252010年7月4日09:01:59)[MSC v.1500 32位(英特尔)]
有关详细信息,请键入“copyright”、“credits”或“license()”。
>>>=================================================重新启动================================
>>>
>>>连接到读卡器:
回溯(最近一次呼叫最后一次):
文件“C:\Users\AmirEbrahim\Desktop\metro.py”,第195行,在
m、 连接()
文件“C:\Users\AmirEbrahim\Desktop\metro.py”,第63行,在connect中
r=读取器()
文件“C:\Python27\lib\site packages\smartcard\System.py”,第41行,在readers中
返回smartcard.reader.ReaderFactory.ReaderFactory.readers(组)
文件“C:\Python27\lib\site packages\smartcard\reader\ReaderFactory.py”,第58行,在readers中
zreaders+=fm(组)
文件“C:\Python27\lib\site packages\smartcard\pcsc\PCSCReader.py”,第107行,在读卡器中
hcontext=PCSCContext().getContext()
文件“C:\Python27\lib\site packages\smartcard\pcsc\PCSCContext.py”,第53行,在\uu init中__
PCSCContext.instance=PCSCContext.\uu PCSCContextSingleton()
文件“C:\Python27\lib\site packages\smartcard\pcsc\PCSCContext.py”,第40行,在\uu init中__
引发EstablishContextException(hresult)
EstablishContextException:
>>>
怎么了?我从下载并安装了PyScard的旧版本,现在它运行正常。
可能是权限问题?你试过当管理员吗?@Bernhard,是的,我已经试过了,没什么变化。