Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#993574: python3-virtualsmartcard: Cannot import virtualsmartcard module

221 views
Skip to first unread message

Robin Krahl

unread,
Sep 3, 2021, 5:30:03 AM9/3/21
to
Package: python3-virtualsmartcard
Version: 3.3+dfsg-2
Severity: important

Dear Maintainer,

after installing the python3-virtualsmartcard package, I cannot import
it with python3:

$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualsmartcard
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'virtualsmartcard'

As far as I see, this is because the package is installed into
/usr/lib/python3/site-packages instead of <..>/dist-packages:

$ apt-file show python3-virtualsmartcard | grep __init__.py
python3-virtualsmartcard: /usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard/__init__.py
python3-virtualsmartcard: /usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard/cards/__init__.py

$ python3 -m site
sys.path = [
'/home/robin',
'/usr/lib/python39.zip',
'/usr/lib/python3.9',
'/usr/lib/python3.9/lib-dynload',
'/usr/local/lib/python3.9/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/robin/.local' (exists)
USER_SITE: '/home/robin/.local/lib/python3.9/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

If I manually put that folder in the Python path, for example by linking
/usr/lib/python3/site-packages/virtualsmartcard/virtualsmartcard to
~/.local/lib/python3.9/site-package/virtualsmartcard, I can at least
import the virtualsmartcard module. But there seem to be missing
dependencies:

>>> import virtualsmartcard.VirtualSmartcard
Traceback (most recent call last):
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CryptoUtils.py", line 29, in <module>
from Crypto.Cipher import DES3, DES, AES, ARC4 # @UnusedImport
ModuleNotFoundError: No module named 'Crypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/VirtualSmartcard.py", line 31, in <module>
from virtualsmartcard.CardGenerator import CardGenerator
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CardGenerator.py", line 34, in <module>
from virtualsmartcard.SmartcardSAM import SAM
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/SmartcardSAM.py", line 24, in <module>
import virtualsmartcard.CryptoUtils as vsCrypto
File "/home/robin/.local/lib/python3.9/site-packages/virtualsmartcard/CryptoUtils.py", line 35, in <module>
import sha as SHA1
ModuleNotFoundError: No module named 'sha'

-- System Information:
Debian Release: 11.0
APT prefers stable-security
APT policy: (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-8-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-virtualsmartcard depends on:
ii python3 3.9.2-3

python3-virtualsmartcard recommends no packages.

python3-virtualsmartcard suggests no packages.

-- no debconf information

Guinness

unread,
Sep 3, 2021, 10:40:04 AM9/3/21
to
Hi,

It seems very logical to me that it cannot import virtualsmartcard if
it's in site-packages and not dist-packages.
I'll have a look at the debian rules to patch it and upload it here, or
if Philippe allows me, package it and have it uploaded by my mentor
nicoo.

Best regards,
--
Guinness
signature.asc

Philippe Thierry

unread,
Sep 6, 2021, 4:40:04 AM9/6/21
to
Hi Guinness,

It is indeed an error in the rules file. If you already have the patch ready, your can upload a NMU release if you wish.
If not, I can handle it during the current week.

Keep me informed of what you prefer :-)

Best regards,
signature.asc

Michael Weghorn

unread,
Jul 23, 2022, 6:20:07 PM7/23/22
to
Hi,

is there any chance to get a fixed package released sometime soon?

The following change fixed this for me in a local rebuild of the
package, but there might be a better way to handle it:

diff --git a/debian/python3-virtualsmartcard.install
b/debian/python3-virtualsmartcard.install
index 47ee4d3..ded283b 100644
--- a/debian/python3-virtualsmartcard.install
+++ b/debian/python3-virtualsmartcard.install
@@ -1 +1 @@
-usr/lib/python3.*/site-packages/virtualsmartcard
/usr/lib/python3/site-packages/virtualsmartcard
+usr/lib/python3.*/site-packages/virtualsmartcard
usr/lib/python3/dist-packages/


Side note: With this in place, I still ran into another problem,
described in upstream issue
https://github.com/frankmorgner/vsmartcard/issues/218
("ModuleNotFoundError: No module named 'sha'").
With a logical backport of the suggested upstream PR
https://github.com/frankmorgner/vsmartcard/pull/228 , running `vicc`
then works without errors for me. Backport in the patch-queue branch of
my local package looks like this:

diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py
b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py
index 56e0ed4..552cff1 100644
--- a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py
+++ b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py
@@ -27,12 +27,11 @@ from virtualsmartcard.utils import inttostring
try:
# Use PyCrypto (if available)
from Crypto.Cipher import DES3, DES, AES, ARC4 # @UnusedImport
- from Crypto.Hash import HMAC, SHA as SHA1
+ from Crypto.Hash import HMAC

except ImportError:
# PyCrypto not available. Use the Python standard library.
import hmac as HMAC
- import sha as SHA1

CYBERFLEX_IV = b'\x00' * 8


Best regards,
Michael

OpenPGP_signature

Michael Weghorn

unread,
Aug 8, 2022, 5:00:04 PM8/8/22
to
> (...) With this in place, I still ran into another problem,
> described in upstream issue
> https://github.com/frankmorgner/vsmartcard/issues/218
> ("ModuleNotFoundError: No module named 'sha'").
> With a logical backport of the suggested upstream PR
> https://github.com/frankmorgner/vsmartcard/pull/228 , running `vicc`
> then works without errors for me. Backport in the patch-queue branch of
> my local package looks like this:
> (...)

FWIW, that upstream pull request has been merged now.
0 new messages