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
875 stars 125 forks source link

ModuleNotFoundError: No module named 'smartcard' (arm64, pip installation) + Fix! #406

Closed hewers closed 3 years ago

hewers commented 3 years ago
Traceback (most recent call last):                                            
  File "/home/user/.local/bin/ykman", line 5, in <module>
    from ykman.cli.__main__ import main       
  File "/home/user/.local/lib/python3.8/site-packages/ykman/__init__.py", line 29, in <module>
    from .device import (  # noqa
  File "/home/user/.local/lib/python3.8/site-packages/ykman/device.py", line 54, in <module>
    from .pcsc import list_devices as _list_ccid_devices           
  File "/home/user/.local/lib/python3.8/site-packages/ykman/pcsc/__init__.py", line 33, in <module>
    from smartcard import System
ModuleNotFoundError: No module named 'smartcard'

Fix: sudo apt install python3-pyscard

I don't know enough about packages and dependencies. This is a bare-bones Ubuntu with almost no default packages. Maybe python3-pyscard needs to be added as a yubikey-manager dependency?

dainnilsson commented 3 years ago

Installation from pip should pull in all required python dependencies, including pyscard. You probably no longer have the output of running the pip install command, but do you recall if there were any errors during installation? Some additional packages are likely required on a fresh Ubuntu for the pyscard build to succeed. Of the top of my head I believe these are swig and libpcsclite-dev (both available via apt).

EDIT: Also note that pcscd needs to be installed and running for any smartcard related functionality in ykman to work.

hewers commented 3 years ago

Ah! I did have a broken dependency when using apt to install the PPA release, for something like python3-yubikey-manager, 3.1.1-1 expected but 3.1.2-focal to be installed

I gave up on that and tried pip.

Thanks!

dainnilsson commented 3 years ago

Ok, sounds like you may have had a broken install of pyscard then. Glad you got it working!