LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
383 stars 110 forks source link

pyscard installation via pip fails on win7 x64 (missing dependencys?) #55

Closed DPSB closed 2 years ago

DPSB commented 6 years ago

Hello,

i'm trying to install pyscard but pip installation fails. Seems like missing dependency's(?) OS Win 7-x64 Command: python -m pip install pyscard Tested with Python 3.4.4-x64, 3.4.4-x86, 3.6.2-x64, 3.6.2-x86

Output from Pycharm


Collecting pyscard
  Using cached pyscard-1.9.6.tar.gz
Installing collected packages: pyscard
  Running setup.py install for pyscard: started
    Running setup.py install for pyscard: finished with status 'error'
    Complete output from command F:\Python\Python3-6-2-x86\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-f4lnwpya-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    building 'smartcard.scard._scard' extension
    swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
    swig.exe -python -outdir smartcard/scard -DWIN32 -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
    error: command 'swig.exe' failed: No such file or directory

Command "F:\Python\Python3-6-2-x86\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-f4lnwpya-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\luckystrike\AppData\Local\Temp\pycharm-packaging\pyscard\

Output from CMD


F:\Python\Python3-4-4-x64>python -m pip install pyscard
Collecting pyscard
  Using cached pyscard-1.9.6.tar.gz
Installing collected packages: pyscard
  Running setup.py install for pyscard ... error
    Complete output from command F:\Python\Python3-4-4-x64\python.exe -u -c "imp
ort setuptools, tokenize;__file__='C:\\Users\\LUCKYS~1\\AppData\\Local\\Temp\\pi
p-build-toq198jf\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__)
;code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exe
c'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-4sq8kep9-record\
install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    building 'smartcard.scard._scard' extension
    swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
    swig.exe -python -outdir smartcard/scard -DWIN32 -o smartcard/scard/scard_wr
ap.c smartcard/scard/scard.i
    error: command 'swig.exe' failed: No such file or directory

Command "F:\Python\Python3-4-4-x64\python.exe -u -c "import setuptools, tokenize
;__file__='C:\\Users\\LUCKYS~1\\AppData\\Local\\Temp\\pip-build-toq198jf\\pyscar
d\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C
:\Users\LUCKYS~1\AppData\Local\Temp\pip-4sq8kep9-record\install-record.txt --sin
gle-version-externally-managed --compile" failed with error code 1 in C:\Users\L
UCKYS~1\AppData\Local\Temp\pip-build-toq198jf\pyscard\

Swig.exe failed No such file or directory I'll guess this is some undocumented dependency? http://www.swig.org/download.html This one? Which version?

LudovicRousseau commented 6 years ago

Install SWIG http://www.swig.org/ It is not a Python package.

DPSB commented 6 years ago

Thx, installing now swigwin-3.0.12 and try it out.

Would be nice to have a note on the documentation that SWIG is needed along with all other not mentioned dependencys. Maybe also the Swig version which the author uses. (for compability) (I'll bet its not installed on most Windows Systems)

Ok, Swig error is gone after downloading latest windows pre-build version and adding it to OS path variable, but now the next dependency is missing:

Collecting pyscard
  Using cached pyscard-1.9.6.tar.gz
Installing collected packages: pyscard
  Running setup.py install for pyscard: started
    Running setup.py install for pyscard: finished with status 'error'
    Complete output from command F:\Python\Python3-4-4-x64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-f_gwlvrd-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    building 'smartcard.scard._scard' extension
    swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
    C:\Tools\swigwin-3.0.12\swig.exe -python -outdir smartcard/scard -DWIN32 -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
    error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).

    ----------------------------------------

Command "F:\Python\Python3-4-4-x64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-f_gwlvrd-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\luckystrike\AppData\Local\Temp\pycharm-packaging\pyscard\

So Visual C++ 10.0 is required too, anything else needed?

DPSB commented 6 years ago

After installing VC 2010 Express i got the following error:

Pycharm:


Collecting pyscard
  Using cached pyscard-1.9.6.tar.gz
Installing collected packages: pyscard
  Running setup.py install for pyscard: started
    Running setup.py install for pyscard: finished with status 'error'
    Complete output from command F:\Python\Python3-4-4-x64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-xdbjx2gy-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    building 'smartcard.scard._scard' extension
    swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
    C:\Tools\swigwin-3.0.12\swig.exe -python -outdir smartcard/scard -DWIN32 -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\luckystrike\AppData\Local\Temp\pycharm-packaging\pyscard\setup.py", line 165, in <module>
        setup(**kw)
      File "F:\Python\Python3-4-4-x64\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "F:\Python\Python3-4-4-x64\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "F:\Python\Python3-4-4-x64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "F:\Python\Python3-4-4-x64\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "F:\Python\Python3-4-4-x64\lib\distutils\command\install.py", line 539, in run
        self.run_command('build')
      File "F:\Python\Python3-4-4-x64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "F:\Python\Python3-4-4-x64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "F:\Python\Python3-4-4-x64\lib\distutils\command\build.py", line 126, in run
        self.run_command(cmd_name)
      File "F:\Python\Python3-4-4-x64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "F:\Python\Python3-4-4-x64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\luckystrike\AppData\Local\Temp\pycharm-packaging\pyscard\setup.py", line 91, in run
        self.run_command('build_ext')
      File "F:\Python\Python3-4-4-x64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "F:\Python\Python3-4-4-x64\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "F:\Python\Python3-4-4-x64\lib\site-packages\setuptools\command\build_ext.py", line 49, in run
        _build_ext.run(self)
      File "F:\Python\Python3-4-4-x64\lib\distutils\command\build_ext.py", line 339, in run
        self.build_extensions()
      File "F:\Python\Python3-4-4-x64\lib\distutils\command\build_ext.py", line 448, in build_extensions
        self.build_extension(ext)
      File "F:\Python\Python3-4-4-x64\lib\site-packages\setuptools\command\build_ext.py", line 174, in build_extension
        _build_ext.build_extension(self, ext)
      File "F:\Python\Python3-4-4-x64\lib\distutils\command\build_ext.py", line 503, in build_extension
        depends=ext.depends)
      File "F:\Python\Python3-4-4-x64\lib\distutils\msvc9compiler.py", line 460, in compile
        self.initialize()
      File "F:\Python\Python3-4-4-x64\lib\distutils\msvc9compiler.py", line 371, in initialize
        vc_env = query_vcvarsall(VERSION, plat_spec)
      File "F:\Python\Python3-4-4-x64\lib\site-packages\setuptools\msvc9_support.py", line 52, in query_vcvarsall
        return unpatched['query_vcvarsall'](version, *args, **kwargs)
      File "F:\Python\Python3-4-4-x64\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
        raise ValueError(str(list(result.keys())))
    ValueError: ['path']

Command "F:\Python\Python3-4-4-x64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\luckystrike\\AppData\\Local\\Temp\\pycharm-packaging\\pyscard\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\LUCKYS~1\AppData\Local\Temp\pip-xdbjx2gy-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\luckystrike\AppData\Local\Temp\pycharm-packaging\pyscard\
LudovicRousseau commented 6 years ago

I do not use or know Windows. I can't really help you.

You can get (automatic builds) binary installers for Windows at https://ci.appveyor.com/project/LudovicRousseau/pyscard, then select your Python and system configuration, then go to Artefacts.

LudovicRousseau commented 6 years ago

The building documentation is at https://github.com/LudovicRousseau/pyscard/blob/master/README

micsthepick commented 6 years ago

It took me a while to find the binaries, as the link just redirects you to a different page. What you need to do if this is happening is to go directly to https://ci.appveyor.com/project/LudovicRousseau/pyscard, look under "JOB NAME" for the correct environment, copy the address that is linked there, and paste it into the url box, adding /artifacts to the end.

rask commented 6 years ago

Same problem on Ubuntu 17.10. Installing swig3.0 fixed the issue.

# sudo apt-get install swig3.0
LudovicRousseau commented 6 years ago

Does someone knows how to define a dependency on swig3 in setup.py? The idea is to get a more explicit error message.

wzulfikar commented 5 years ago

the pip install pyscard also fails in mac. installing swig (inspired from @rask answer) from brew using brew install swig and re-running pip install pyscard did the job.

Hunu commented 5 years ago

In case of someone else meet the same issue: I'm running win10x64 and had the same error as DPSB. After a lot of searching, I found swig is available in chocolately package manager My solution was

  1. Install the chocolately package manager
  2. Open a powershell as administrator mode, run choco install swig
  3. Then in the same window, install pyscard by pip install pyscard And done!
LudovicRousseau commented 5 years ago

Thanks @Hunu

I updated the install documentation https://github.com/LudovicRousseau/pyscard/blob/master/INSTALL.md#installing-on-windows-from-the-source-distribution

merlokk commented 5 years ago

Sometimes it just need to install full VisualStudio community edition with python. it depends on what libraries have installed on pc.

LudovicRousseau commented 5 years ago

Pypi now provides 2 windows Wheel files (from https://ci.appveyor.com/project/LudovicRousseau/pyscard):

It should be simple to install one of these with pip install

DPSB commented 5 years ago

Sometimes it just need to install full VisualStudio community edition with python. it depends on what libraries have installed on pc.

This may be a temporary workaround, but totally unacceptable for productive use. Why install a oversized IDE when only requiring 1 or 2 files.

Pypi now provides 2 windows Wheel files (from https://ci.appveyor.com/project/LudovicRousseau/pyscard):

* pyscard-1.9.8-cp27-cp27m-win_amd64.whl

* pyscard-1.9.8-cp36-cp36m-win_amd64.whl

It should be simple to install one of these with pip install

Thanks, i will test it within the next couple of days and report back

LudovicRousseau commented 2 years ago

From my experience I have no issues with pyscard when install Python from miniconda https://docs.conda.io/en/latest/miniconda.html