jbuitt / nwws-python-client

Python client for downloading products from NOAA Weather Wire
https://github.com/jbuitt/nwws-python-client
MIT License
10 stars 10 forks source link

python3, *buntu 22.04 and MutableSet errors #4

Closed ScanCaster closed 10 months ago

ScanCaster commented 1 year ago

Using FRESH INSTALL on:

*Buntu based: 22.04 /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="DragonOS FocalX R29.1

Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux

~/NWWS$ sudo apt-get install python3-sleekxmpp Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: python3-dnspython python3-gnupg python3-pyasn1 python3-pyasn1-modules python3-requests-toolbelt python3-socks Suggested packages: python3-sniffio python3-trio The following NEW packages will be installed: python3-dnspython python3-gnupg python3-pyasn1 python3-pyasn1-modules python3-requests-toolbelt python3-sleekxmpp python3-socks 0 upgraded, 7 newly installed, 0 to remove and 127 not upgraded. Need to get 1,167 kB of archives. After this operation, 6,238 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-dnspython all 2.1.0-1ubuntu1 [123 kB] Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 python3-gnupg all 0.4.8-1 [19.4 kB] Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-pyasn1 all 0.4.8-1 [50.9 kB] Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-pyasn1-modules all 0.2.1-1 [33.0 kB] Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-requests-toolbelt all 0.9.1-1 [38.0 kB] Get:6 http://archive.ubuntu.com/ubuntu jammy/universe amd64 python3-sleekxmpp all 1.3.3-6 [881 kB] Get:7 http://archive.ubuntu.com/ubuntu jammy/universe amd64 python3-socks all 1.7.1+dfsg-1 [22.4 kB] Fetched 1,167 kB in 11s (110 kB/s)
Selecting previously unselected package python3-dnspython. (Reading database ... 407052 files and directories currently installed.) Preparing to unpack .../0-python3-dnspython_2.1.0-1ubuntu1_all.deb ... Unpacking python3-dnspython (2.1.0-1ubuntu1) ... Selecting previously unselected package python3-gnupg. Preparing to unpack .../1-python3-gnupg_0.4.8-1_all.deb ... Unpacking python3-gnupg (0.4.8-1) ... Selecting previously unselected package python3-pyasn1. Preparing to unpack .../2-python3-pyasn1_0.4.8-1_all.deb ... Unpacking python3-pyasn1 (0.4.8-1) ... Selecting previously unselected package python3-pyasn1-modules. Preparing to unpack .../3-python3-pyasn1-modules_0.2.1-1_all.deb ... Unpacking python3-pyasn1-modules (0.2.1-1) ... Selecting previously unselected package python3-requests-toolbelt. Preparing to unpack .../4-python3-requests-toolbelt_0.9.1-1_all.deb ... Unpacking python3-requests-toolbelt (0.9.1-1) ... Selecting previously unselected package python3-sleekxmpp. Preparing to unpack .../5-python3-sleekxmpp_1.3.3-6_all.deb ... Unpacking python3-sleekxmpp (1.3.3-6) ... Selecting previously unselected package python3-socks. Preparing to unpack .../6-python3-socks_1.7.1+dfsg-1_all.deb ... Unpacking python3-socks (1.7.1+dfsg-1) ... Setting up python3-gnupg (0.4.8-1) ... Setting up python3-requests-toolbelt (0.9.1-1) ... Setting up python3-socks (1.7.1+dfsg-1) ... Setting up python3-dnspython (2.1.0-1ubuntu1) ... Setting up python3-pyasn1 (0.4.8-1) ... Setting up python3-pyasn1-modules (0.2.1-1) ... Setting up python3-sleekxmpp (1.3.3-6) ...

On my 20.04 box, it runs, there is an issue with my NWWS creds for some reason on it, so it fails to authenticate, but thats my issue, I will deal with ...

On the 22.04 OS I get this

Starting up on this gets the following error:

python3 nwws.py config.json Traceback (most recent call last): File "/home/re9140/NWWS/nwws.py", line 10, in import sleekxmpp File "/usr/lib/python3/dist-packages/sleekxmpp/init.py", line 20, in from sleekxmpp.stanza import Message, Presence, Iq File "/usr/lib/python3/dist-packages/sleekxmpp/stanza/init.py", line 10, in from sleekxmpp.stanza.error import Error File "/usr/lib/python3/dist-packages/sleekxmpp/stanza/error.py", line 9, in from sleekxmpp.xmlstream import ElementBase, ET File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/init.py", line 14, in from sleekxmpp.xmlstream.xmlstream import XMLStream, RESPONSE_TIMEOUT File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 35, in from sleekxmpp.thirdparty.statemachine import StateMachine File "/usr/lib/python3/dist-packages/sleekxmpp/thirdparty/init.py", line 2, in from sleekxmpp.thirdparty.orderedset import OrderedSet File "/usr/lib/python3/dist-packages/sleekxmpp/thirdparty/orderedset.py", line 25, in class OrderedSet(collections.MutableSet): AttributeError: module 'collections' has no attribute 'MutableSet'

Possibly:

https://stackoverflow.com/questions/74006130/attributeerror-module-collections-has-no-attribute-mutableset

in the new version of python collections have no more MutableSet, MutableMapping, etc.. But the module collections.abc have it so if you want you can go like this:

import collections import sys if sys.version_info.major == 3 and sys.version_info.minor >= 10: from collections.abc import MutableSet collections.MutableSet = collections.abc.MutableSet else: from collections import MutableSet

ScanCaster commented 1 year ago

Ok this is HOW TO FIX the issue for Python 3.10.

Tested on *buntu based 22.04 (DragonOSFocalX 29.2)

The 3rd party code of SleekXMPP needs to be UPDATED to the NEW 3.10 library which provides the functions needed.

See my FORK here on fixing it... https://github.com/ScanCaster/nwws-python-client

Changing the code in the orderedset.py fixes the error I reported.. I have an issue withe NWS in re creds, to resolve, I think this will fix things to operate though.

I will advise once I get the cred/auth issue with NWS resolved.

There definitely is some more clean up to this fix needed, but this I think gets things going and cleaning it up.

DO NOT USE ON PYTHON 3.9 or LESS. ONLY USE ON 3.10 OR GREATER!!!!!

Any one with issues in other operations let me know there may need to be more edits to get all the libs referenced correctly.

jbuitt commented 1 year ago

Thank you for this find!

Would you mind submitting a pull request to make this change? I would be happy to merge it in after testing.

Jim

ScanCaster commented 1 year ago

I created a PR for this... I am not a git user by norm for coding.. I am much more old school on that....

BUT

Also this is for python 3.10 or latter 3.9 and lower is fine as I can tell. So as I put in the PR there likely would be best practice to make some changes to check on python version and how that is imported... Or maybe at the packaging level for the distro... ie: 22.10+ on buntus will need this, I am not sure about Debian, but it will be close to there as buntus base off Debian, same with Mint etc... Can't speak to outside the Debian sphere as I don't use those.

Hope this helps others..

Glad to assist more if I can.

jbuitt commented 1 year ago

Hey @ScanCaster ! I finally had a chance to look into this a bit more yesterday and also found that as you stated, the SleekXMPP library needs to be updated to account for the new collections. In the meantime, I verified that running the two commands below locally will allow my existing nwws.py script to work with no other changes on Ubuntu 22.04:

sed -i.orig 's/^import collections/import collections.abc/' /usr/lib/python3/dist-packages/sleekxmpp/thirdparty/orderedset.py
sed -i.orig 's/^class OrderedSet(collections.MutableSet):/class OrderedSet(collections.abc.MutableSet):/' /usr/lib/python3/dist-packages/sleekxmpp/thirdparty/orderedset.py

I will add this comment into the README.md of my repo for users on Ubuntu 22.04. Since this is an issue in the SleekXMPP library and not nwws.py itself, I'll also go ahead and close your PR.

Thanks!

jbuitt commented 10 months ago

Closed due to inactivity