0

我已经下载了 Python-2.7pyscard-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 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>
>>>

怎么了?

4

1 回答 1

0

我从这里下载并安装了旧版本的 PyScard ,现在它工作正常。 在此处输入图像描述

于 2015-07-26T10:07:03.057 回答