On Fri, Apr 30, 2021 at 03:57:21PM +0200, Niels ten Oever wrote:
$ sudo apt install python3-construct
So you are on a debian based system? That really puzzles me because I never had
any trouble of installed packages not being importable.
Now before I go on and suggest that you do a clean installation of your distro,
I decided to try pysim myself on my current debian testing system.
I get this:
▶ ./pySim-read.py
Traceback (most recent call last):
File "/home/neels/s/pysim/./pySim-read.py", line 31, in <module>
from pySim.ts_51_011 import EF, DF, EF_SST_map, EF_AD
File "/home/neels/s/pysim/pySim/ts_51_011.py", line 329, in <module>
from pySim.filesystem import *
File "/home/neels/s/pysim/pySim/filesystem.py", line 32, in <module>
from cmd2 import CommandSet, with_default_category, with_argparser
ImportError: cannot import name 'CommandSet' from 'cmd2'
(/usr/lib/python3/dist-packages/cmd2.py)
after I did this:
git clone ssh://go/pysim
cd pysim/
sudo apt-get install python3-pyscard python3-serial python3-cmd2 python3-construct
sudo pip3 install pytlv
sudo pip3 install jsonpath-ng
▶ python3 --version
Python 3.9.2
So I'm also having problems.
Resolving them:
▶ ipython3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import cmd2
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-39a0469425e0> in <module>
----> 1 import cmd2
~/s/cmd2/cmd2/__init__.py in <module>
20 from typing import List
21
---> 22 from .ansi import style, fg, bg
23 from .argparse_custom import Cmd2ArgumentParser, Cmd2AttributeWrapper,
CompletionItem, set_default_argument_parser
24
~/s/cmd2/cmd2/ansi.py in <module>
17 )
18
---> 19 import colorama # type: ignore [import]
20 from colorama import (
21 Back,
ModuleNotFoundError: No module named 'colorama'
I would expect that a generic text prompt library would be able to at least
*start* without color support installed.
(but later on I find out the debian testing version of cmd2 is super old)
▶ sudo apt-get install python3-colorama
▶ ipython3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import cmd2
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-39a0469425e0> in <module>
----> 1 import cmd2
~/s/cmd2/cmd2/__init__.py in <module>
34 # Get the current value for argparse_custom.DEFAULT_ARGUMENT_PARSER
35 from .argparse_custom import DEFAULT_ARGUMENT_PARSER
---> 36 from .cmd2 import Cmd
37 from .command_definition import CommandSet, with_default_category
38 from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS
~/s/cmd2/cmd2/cmd2.py in <module>
71 )
72
---> 73 from . import (
74 ansi,
75 constants,
~/s/cmd2/cmd2/plugin.py in <module>
6 )
7
----> 8 import attr
9
10 from .parsing import (
ModuleNotFoundError: No module named 'attr'
WTF, does python3-cmd2.deb not list its dependencies?!
sudo apt-get install python3-attr
▶ ipython3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import cmd2
In [2]:
After this, still the same error as I started out with:
▶ ipython3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from cmd2 import CommandSet
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f665e7ca0d9d> in <module>
----> 1 from cmd2 import CommandSet
ImportError: cannot import name 'CommandSet' from 'cmd2'
(/usr/lib/python3/dist-packages/cmd2.py)
Installed by the debian-testing package is cmd2 version 0.8.5.
The CommandSet class was added in June 2020 in cmd2 1.3.0.
▶ sudo apt-get remove python3-cmd2
▶ sudo pip3 install cmd2
Successfully installed cmd2-1.5.0
So pip3 gets me the latest version of cmd2.
After that, pySim-read.py starts successfully.
But I get this:
▶ ./pySim-read.py -p 0
Using PC/SC reader interface
Card reader initialization failed with exception:
'Failure to establish context: Service not available.'
I remember this, I need to start the PC/SC service or something. I thought it
said so so in the README, alas no such hint is there. So I figure out myself
that it has to be
▶ sudo apt-get install pcscd
▶ sudo systemctl start pcscd
Now I can successfully pySim-read.py my new sysmoISIM-SJA2,
but right in the end there is an error again:
▶ ./pySim-read.py -p 0
Using PC/SC reader interface
Reading ...
Autodetected card type: sysmoISIM-SJA2
ICCID: 89[...]
[...200 lines cut...]
ISIM Service Table: 190200
Service 1 - P-CSCF address
Service 4 - GBA-based Local Key Establishment Mechanism
Service 5 - Support of P-CSCF discovery for IMS Local Break Out
Service 10 - Support of UICC access to IMS
Done !
Exception ignored in: <function PCSCCardConnection.__del__ at 0x7fb7b29190d0>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/smartcard/pcsc/PCSCCardConnection.py",
line 88, in __del__
File "/usr/lib/python3/dist-packages/smartcard/pcsc/PCSCCardConnection.py",
line 152, in disconnect
File "/usr/lib/python3/dist-packages/smartcard/scard/scard.py", line 502, in
SCardDisconnect
AttributeError: 'NoneType' object has no attribute 'SCardDisconnect'
So I am also having problems, but it is a different class of problem that
Niels-with-i is seeing, because it was solvable by installing the right
dependencies.
Maybe people active in the pysim.git can take this transcript of getting it
running to improve some things? Maybe mention pcscd in the README? Maybe
mention the cmd2 version required?
I'm back to osmo-bsc now.
~N