Yubico / yubikey-manager

Python library and command line tool for configuring any YubiKey over all USB interfaces.
https://developers.yubico.com/yubikey-manager/
BSD 2-Clause "Simplified" License
876 stars 124 forks source link

pip install yubikey-manager failing #42

Closed ghost closed 6 years ago

ghost commented 6 years ago

pip 9.0.1, python 3.6 on Linux:

$ pip install yubikey-manager
Collecting yubikey-manager
  Using cached yubikey-manager-0.5.0.tar.gz
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from yubikey-manager)
Collecting pyscard (from yubikey-manager)
  Using cached pyscard-1.9.6.tar.gz
Collecting pyusb (from yubikey-manager)
  Using cached pyusb-1.0.2.tar.gz
Collecting click (from yubikey-manager)
  Using cached click-6.7-py2.py3-none-any.whl
Requirement already satisfied: cryptography in /usr/lib/python3.6/site-packages (from yubikey-manager)
Collecting pyopenssl (from yubikey-manager)
  Using cached pyOpenSSL-17.5.0-py2.py3-none-any.whl
Requirement already satisfied: idna>=2.0 in /usr/lib/python3.6/site-packages (from cryptography->yubikey-manager)
Requirement already satisfied: pyasn1>=0.1.8 in /usr/lib/python3.6/site-packages (from cryptography->yubikey-manager)
Requirement already satisfied: setuptools>=11.3 in /usr/lib/python3.6/site-packages (from cryptography->yubikey-manager)
Requirement already satisfied: cffi>=1.4.1 in /usr/lib/python3.6/site-packages (from cryptography->yubikey-manager)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi>=1.4.1->cryptography->yubikey-manager)
Installing collected packages: pyscard, pyusb, click, pyopenssl, yubikey-manager
  Running setup.py install for pyscard ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ipcmpveg/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 /tmp/pip-njt8jum4-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 -python -outdir smartcard/scard -DPCSCLITE -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
    unable to execute 'swig': No such file or directory
    error: command 'swig' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ipcmpveg/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 /tmp/pip-njt8jum4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ipcmpveg/pyscard/

This appears because swig is also a dependency. Installing swig fixes that error, but then I see the following gcc (version: 7.2.1 20180116) error:

Installing collected packages: pyscard, pyusb, click, pyopenssl, yubikey-manager
  Running setup.py install for pyscard ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-x56ben10/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 /tmp/pip-h5s8hpb3-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 -python -outdir smartcard/scard -DPCSCLITE -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
    creating build
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/smartcard
    creating build/temp.linux-x86_64-3.6/smartcard/scard
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -DVER_PRODUCTVERSION=1,9,6,0000 -DVER_PRODUCTVERSION_STR=1.9.6 -DPCSCLITE=1 -Ismartcard/scard/ -I/usr/include/PCSC -I/usr/include/python3.6m -c smartcard/scard/helpers.c -o build/temp.linux-x86_64-3.6/smartcard/scard/helpers.o
    smartcard/scard/helpers.c:28:10: fatal error: winscard.h: No such file or directory
     #include <winscard.h>
              ^~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-x56ben10/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 /tmp/pip-h5s8hpb3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-x56ben10/pyscard/
dagheyman commented 6 years ago

You need the package pcsclite-dev to build pyscard from source, but it may also be available precompiled as python-pyscard in your package manager. What linux distro are you using?

ghost commented 6 years ago

huh, thanks for the explanation @dagheyman. I am using Arch Linux. Is there a recommended way to install this or an equivalent CLI for trying it out?

emlun commented 6 years ago

I think yubikey-manager is in the official Arch repos, and includes the Python library. Or do you specifically need to build from source for another reason?

ghost commented 6 years ago

thanks @emlun I should've checked that before :). I think this issue can be closed with a simple update to the documentation on the website that explains what other dependencies are needed when installing from pip.