Skip to content

I don´t have pacman on Ubuntu and ran into a websocket issue #45

@anlicht

Description

@anlicht

I managed to start scratch_link on Ubuntu 22.04, though Scratch 3.0 does not connect to a micro:bit V2. Since I don´t ran into an issue - other then missing pacman and components it may have installed on Arch - I took a second PC with PopOS 22.04 and ran into a websocket issue that I wanted to share here. I'm not a dev, but willing to learn.

I found #43 and may relate. The thing is, that I don´t have pacman package manager and on both PCs there's probably something missing. Here are the essentials from what I did and the current scratch_link output is at the bottom. Anything I can do about it and maybe add to improving the UX, meaning user experience?

PS: As you will see, I unfortunately had this warning only afterwards: "Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager". So I´d be grateful to go into the pacman thing on the first PC, if I ran into an issue because of this that will not easily be solved.

$ sudo pacman -S bluez bluez-utils nss libcap
sudo: pacman: Befehl nicht gefunden
[...]
$ sudo apt install bluez bluez-utils nss libcap
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Paket bluez-utils ist nicht verfügbar, wird aber von einem anderen Paket
referenziert. Das kann heißen, dass das Paket fehlt, dass es abgelöst
wurde oder nur aus einer anderen Quelle verfügbar ist.
Doch die folgenden Pakete ersetzen es:
bluez:i386 bluez
E: Für Paket »bluez-utils« existiert kein Installationskandidat.
E: Paket nss kann nicht gefunden werden.
E: Paket libcap kann nicht gefunden werden.

$ sudo apt install bluez
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
bluez ist schon die neueste Version (5.64-0ubuntu1.4).
bluez wurde als manuell installiert festgelegt.
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 215 nicht aktualisiert.

$ pip install pyscrlink
Der Befehl 'pip' wurde nicht gefunden, kann aber installiert werden mit:
sudo apt install python3-pip

$ pip3 install pyscrlink
Der Befehl 'pip3' wurde nicht gefunden, kann aber installiert werden mit:
sudo apt install python3-pip

$ sudo apt install python3-pip
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Die folgenden zusätzlichen Pakete werden installiert:
[...]
7 aktualisiert, 12 neu installiert, 0 zu entfernen und 208 nicht aktualisiert.

$ pip install pyscrlink
Defaulting to user installation because normal site-packages is not writeable
Collecting pyscrlink
Downloading pyscrlink-0.2.8-py3-none-any.whl (14 kB)
Collecting bluepy
Downloading bluepy-1.3.0.tar.gz (217 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.9/217.9 KB 2.9 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting websockets
Downloading websockets-15.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (181 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.6/181.6 KB 5.3 MB/s eta 0:00:00
Collecting pyOpenSSL
Downloading pyOpenSSL-25.0.0-py3-none-any.whl (56 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.5/56.5 KB 3.8 MB/s eta 0:00:00
Collecting typing-extensions>=4.9
Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting cryptography<45,>=41.0.5
Downloading cryptography-44.0.2-cp39-abi3-manylinux_2_34_x86_64.whl (4.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 6.5 MB/s eta 0:00:00
Collecting cffi>=1.12
Downloading cffi-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (446 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 446.2/446.2 KB 5.3 MB/s eta 0:00:00
Collecting pycparser
Downloading pycparser-2.22-py3-none-any.whl (117 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 KB 4.9 MB/s eta 0:00:00
Building wheels for collected packages: bluepy
Building wheel for bluepy (setup.py) ... done
Created wheel for bluepy: filename=bluepy-1.3.0-cp310-cp310-linux_x86_64.whl size=579969 sha256=87b3ce839480163da47f304a419b9e83692c48e309b5e170ffd72dd65924b381
Stored in directory: /home/wine/.cache/pip/wheels/e6/0b/5d/6f0ee9526d33b28d86d4adfc9f6ae9249ef3a7a3a1b1189d11
Successfully built bluepy
Installing collected packages: bluepy, websockets, typing-extensions, pycparser, cffi, cryptography, pyOpenSSL, pyscrlink
WARNING: The scripts blescan, sensortag and thingy52 are installed in '/home/wine/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script websockets is installed in '/home/wine/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts bluepy_helper_cap and scratch_link are installed in '/home/wine/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed bluepy-1.3.0 cffi-1.17.1 cryptography-44.0.2 pyOpenSSL-25.0.0 pycparser-2.22 pyscrlink-0.2.8 typing-extensions-4.12.2 websockets-15.0.1

$ sudo pip install pyscrlink
Collecting pyscrlink
Downloading pyscrlink-0.2.8-py3-none-any.whl (14 kB)
Collecting pyOpenSSL
Downloading pyOpenSSL-25.0.0-py3-none-any.whl (56 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.5/56.5 KB 1.3 MB/s eta 0:00:00
Collecting bluepy
Downloading bluepy-1.3.0.tar.gz (217 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.9/217.9 KB 3.8 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting websockets
Downloading websockets-15.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (181 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.6/181.6 KB 5.0 MB/s eta 0:00:00
Collecting cryptography<45,>=41.0.5
Downloading cryptography-44.0.2-cp39-abi3-manylinux_2_34_x86_64.whl (4.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 4.7 MB/s eta 0:00:00
Collecting typing-extensions>=4.9
Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting cffi>=1.12
Downloading cffi-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (446 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 446.2/446.2 KB 5.0 MB/s eta 0:00:00
Collecting pycparser
Downloading pycparser-2.22-py3-none-any.whl (117 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 KB 4.4 MB/s eta 0:00:00
Building wheels for collected packages: bluepy
Building wheel for bluepy (setup.py) ... done
Created wheel for bluepy: filename=bluepy-1.3.0-cp310-cp310-linux_x86_64.whl size=579963 sha256=31f6604a25622e0be1816ab33fb75c876e6f47079ade63608b1bfecf026bd8e5
Stored in directory: /root/.cache/pip/wheels/e6/0b/5d/6f0ee9526d33b28d86d4adfc9f6ae9249ef3a7a3a1b1189d11
Successfully built bluepy
Installing collected packages: bluepy, websockets, typing-extensions, pycparser, cffi, cryptography, pyOpenSSL, pyscrlink
Attempting uninstall: cryptography
Found existing installation: cryptography 3.4.8
Not uninstalling cryptography at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'cryptography'. No files were found to uninstall.
Successfully installed bluepy-1.3.0 cffi-1.17.1 cryptography-44.0.2 pyOpenSSL-25.0.0 pycparser-2.22 pyscrlink-0.2.8 typing-extensions-4.12.2 websockets-15.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

$ bluepy_helper_cap
Set capacbility 'cap_net_raw,cap_net_admin' to /home/wine/.local/lib/python3.10/site-packages/bluepy/bluepy-helper

$ scratch_link
2025-03-21 17:11:50,631 Generated certificate: /home/wine/.local/share/pyscrlink/scratch-device-manager.cer
2025-03-21 17:11:50,631 Generated key: /home/wine/.local/share/pyscrlink/scratch-device-manager.key
2025-03-21 17:11:50,654 Add the new certificate to /home/wine/.mozilla/firefox/97tzdn22.default-release
2025-03-21 17:11:50,713 Certificate is ready in FireFox NSS DB: /home/wine/.mozilla/firefox/97tzdn22.default-release
2025-03-21 17:11:50,857 Add the new certificate to /home/wine/.pki/nssdb
2025-03-21 17:11:50,901 Certificate is ready in Chrome NSS DB: /home/wine/.pki/nssdb
Traceback (most recent call last):
File "/usr/local/bin/scratch_link", line 8, in
sys.exit(main())
File "/home/wine/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 576, in main
start_server = websockets.serve(
File "/home/wine/.local/lib/python3.10/site-packages/websockets/asyncio/server.py", line 743, in init
self.server = Server(
File "/home/wine/.local/lib/python3.10/site-packages/websockets/asyncio/server.py", line 284, in init
self.loop = asyncio.get_running_loop()
RuntimeError: no running event loop

$ sudo apt install libpcap-dev
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Die folgenden zusätzlichen Pakete werden installiert:
libdbus-1-dev libpcap0.8-dev
Die folgenden NEUEN Pakete werden installiert:
libdbus-1-dev libpcap-dev libpcap0.8-dev
0 aktualisiert, 3 neu installiert, 0 zu entfernen und 208 nicht aktualisiert.

$ sudo apt install libcap-dev
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Die folgenden zusätzlichen Pakete werden installiert:
libcap2 libcap2:i386
Die folgenden NEUEN Pakete werden installiert:
libcap-dev
Die folgenden Pakete werden aktualisiert (Upgrade):
libcap2 libcap2:i386
2 aktualisiert, 1 neu installiert, 0 zu entfernen und 206 nicht aktualisiert.

$ python3 --version
Python 3.10.12

$ python3 -m pip show asyncio
WARNING: Package(s) not found: asyncio
$ pip install asyncio
[...]
$ python3 -m pip show asyncio
Name: asyncio
Version: 3.4.3
Summary: reference implementation of PEP 3156
Home-page: http://www.python.org/dev/peps/pep-3156/
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/wine/.local/lib/python3.10/site-packages
Requires:
Required-by:

$ scratch_link
2025-03-21 18:06:41,186 Certificate is ready in FireFox NSS DB: /home/wine/.mozilla/firefox/97tzdn22.default-release
2025-03-21 18:06:41,223 Certificate is ready in Chrome NSS DB: /home/wine/.pki/nssdb
Traceback (most recent call last):
File "/usr/local/bin/scratch_link", line 8, in
sys.exit(main())
File "/home/wine/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 576, in main
start_server = websockets.serve(
File "/home/wine/.local/lib/python3.10/site-packages/websockets/asyncio/server.py", line 743, in init
self.server = Server(
File "/home/wine/.local/lib/python3.10/site-packages/websockets/asyncio/server.py", line 284, in init
self.loop = asyncio.get_running_loop()
RuntimeError: no running event loop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions