Hi all,
I am a happy user of pySim - thanks a lot for the work on it. Unfortunately, I think something broke during recent updates that might have to do with software versions.
I went through a full reinstall and have done all the software installations mentioned in the README.md, but when I do:
$ ./pySim-read.py -p0
I get:
Traceback (most recent call last): File "./pySim-read.py", line 31, in <module> from pySim.ts_51_011 import EF, DF, EF_SST_map, EF_AD File "/home/gagarin/Data/pysim/pySim/ts_51_011.py", line 324, in <module> from construct import * ModuleNotFoundError: No module named 'construct'
I tried:
$ sudo pip3 install construct Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (2.10.67)
But that did not solve the issue.
Any pointers are very welcome.
All the best,
Niels
PS FYI: $ cat /proc/version Linux version 5.8.0-50-generic (buildd@lgw01-amd64-051) (gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0, GNU ld (GNU Binutils for Ubuntu) 2.35.1) #56-Ubuntu SMP Mon Apr 12 17:18:36 UTC 2021
$ lsusb | grep OMNI Bus 001 Device 033: ID 076b:3031 OmniKey AG OMNIKEY 3x21 Smart Card Reader
Hi Niels,
On Wed, Apr 28, 2021 at 07:18:34PM +0200, Niels ten Oever wrote:
I am a happy user of pySim - thanks a lot for the work on it. Unfortunately, I think something broke during recent updates that might have to do with software versions.
pySim has recently been extended heavily, which introduced some new dependencies, and those should all be documented in the README, but also
I went through a full reinstall and have done all the software installations mentioned in the README.md, but when I do:
$ ./pySim-read.py -p0
which python version are you using to execute pySim?
$ sudo pip3 install construct Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (2.10.67)
so it is installed for python3.8.
But that did not solve the issue.
I suspect you installed 'construct' for python3.8 but you are executing pySim-reads by some other version of python? What does the following command tell you:
/usr/bin/env python3 --version
I would assume it shows something else than python 3.8.x ?
Hi Harald,
Thanks for your quick response, please find my reply below in-line:
On 28-04-2021 21:36, Harald Welte wrote:
Hi Niels,
On Wed, Apr 28, 2021 at 07:18:34PM +0200, Niels ten Oever wrote:
I am a happy user of pySim - thanks a lot for the work on it. Unfortunately, I think something broke during recent updates that might have to do with software versions.
pySim has recently been extended heavily, which introduced some new dependencies, and those should all be documented in the README, but also
I went through a full reinstall and have done all the software installations mentioned in the README.md, but when I do:
$ ./pySim-read.py -p0
$ /usr/bin/env python3 --version Python 3.8.5
which python version are you using to execute pySim?
See above
$ sudo pip3 install construct Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (2.10.67)
so it is installed for python3.8.
$ sudo pip3 install construct Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (2.10.67)
Indeed
But that did not solve the issue.
I suspect you installed 'construct' for python3.8 but you are executing pySim-reads by some other version of python? What does the following command tell you:
/usr/bin/env python3 --version
I would assume it shows something else than python 3.8.x ?
Unfortunately not, but all other suggestions are welcome!
Best,
Niels
Your report seems really odd and not related to pysim but rather some unfortunate mixup of python library installation. Hard to tell from the distance.
Have you tried maybe running 'python3' (or 'ipython3') and entering import construct on the prompt?
Is there maybe some discrepancy between /usr/local/lib, /usr/lib and your ~/.local/lib python library locations?
Maybe try running from a different user account, just in case your user's python config is somehow confused?
~N
Thanks Neels,
I got one step further by running:
$ sudo apt install python3-construct
and felt kinda stupid when that worked.
Unfortunately that did not solve all my issues, because then I got:
./pySim-read.py -p0 1 ↵ ⚙ 1061 15:38:08 Traceback (most recent call last): File "/home/gagarin/.local/lib/python3.8/site-packages/qtpy/__init__.py", line 204, in <module> from PySide import __version__ as PYSIDE_VERSION # analysis:ignore ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "./pySim-read.py", line 31, in <module> from pySim.ts_51_011 import EF, DF, EF_SST_map, EF_AD File "/home/gagarin/Data/pysim/pySim/ts_51_011.py", line 329, in <module> from pySim.filesystem import * File "/home/gagarin/Data/pysim/pySim/filesystem.py", line 31, in <module> import cmd2 File "/home/gagarin/.local/lib/python3.8/site-packages/cmd2/__init__.py", line 30, in <module> from .cmd2 import Cmd File "/home/gagarin/.local/lib/python3.8/site-packages/cmd2/cmd2.py", line 73, in <module> from .clipboard import ( File "/home/gagarin/.local/lib/python3.8/site-packages/cmd2/clipboard.py", line 14, in <module> _ = pyperclip.paste() File "/home/gagarin/.local/lib/python3.8/site-packages/pyperclip/__init__.py", line 680, in lazy_load_stub_paste copy, paste = determine_clipboard() File "/home/gagarin/.local/lib/python3.8/site-packages/pyperclip/__init__.py", line 582, in determine_clipboard import qtpy # check if qtpy is installed File "/home/gagarin/.local/lib/python3.8/site-packages/qtpy/__init__.py", line 210, in <module> raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found
So I sought to install PySide:
sudo pip3 install -U PySide --no-cache-dir Collecting PySide Downloading PySide-1.2.4.tar.gz (9.3 MB) |████████████████████████████████| 9.3 MB 5.1 MB/s ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-eea4ncap/PySide/setup.py'"'"'; __file__='"'"'/tmp/pip-install-eea4ncap/PySide/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-lu1h2k1z cwd: /tmp/pip-install-eea4ncap/PySide/ Complete output (1 lines): only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)] ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
and it then turned out PySide only support Python up to 3.4. - which was quite surprising to me.
So I thought to set up an anaconda envuronmentwith Python 3.4, but the oldest Python3 version that is support by anaonconda is Python 3.5.4 argh.
My intermediate hypothesis is that things broke with recent Ubuntu update to a more recent Python version?
Thanks for the help and comments that might help me get on my way.
Best,
Niels
On 30-04-2021 13:54, Neels Hofmeyr wrote:
Your report seems really odd and not related to pysim but rather some unfortunate mixup of python library installation. Hard to tell from the distance.
Have you tried maybe running 'python3' (or 'ipython3') and entering import construct on the prompt?
Is there maybe some discrepancy between /usr/local/lib, /usr/lib and your ~/.local/lib python library locations?
Maybe try running from a different user account, just in case your user's python config is somehow confused?
~N
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
Hi Niels,
On Fri, Apr 30, 2021 at 11:56:01AM +0200, Niels ten Oever wrote:
$ /usr/bin/env python3 --version Python 3.8.5
which python version are you using to execute pySim?
strange. Unfortuantely I'm not a python expert, and I'm not sure why the 'construct' you installed using pip3 is not import-able by python.
All I can say is that I tested the new imports on Debian 9, 10 and unstable, and it worked on those platforms.
There certainly are other people on this list who have a much deeper python knowledge than I do.
Hi Niels,
Requirement already satisfied: construct in
/usr/local/lib/python3.8/dist-packages (2.10.67)
you need to make sure that '/usr/local/lib/python3.8/dist-packages' is in the Python's search path (similar to LD_LIBRARY_PATH):
$ python3
import sys sys.path
Here is the output from my system:
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/fixeria/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages']
If '/usr/local/lib/python3.8/dist-packages' is not there, then indeed importing will not work. You will need to re-configure pip to use a proper directory, or add this path to PYTHONPATH. Good luck!
P.S. So now we have Niels and Neels in the thread ;)
Best regards, Vadim.
Thanks all,
I got things working again - thanks again very much for the help!
Best,
Niels
On 30-04-2021 15:51, Vadim Yanitskiy wrote:
Hi Niels,
Requirement already satisfied: construct in /usr/local/lib/python3.8/dist-packages (2.10.67)
you need to make sure that '/usr/local/lib/python3.8/dist-packages' is in the Python's search path (similar to LD_LIBRARY_PATH):
$ python3
import sys sys.path
Here is the output from my system:
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/fixeria/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages']
If '/usr/local/lib/python3.8/dist-packages' is not there, then indeed importing will not work. You will need to re-configure pip to use a proper directory, or add this path to PYTHONPATH. Good luck!
P.S. So now we have Niels and Neels in the thread ;)
Best regards, Vadim.