thingsboard-python-rest-client icon indicating copy to clipboard operation
thingsboard-python-rest-client copied to clipboard

tb-rest-client 3.8.0 does not work on Windows venv ImportError: No module named six.moves (with six version 1.10)

Open rretanubun opened this issue 1 year ago • 5 comments

OS: windows OS (win-11 23H2) Python version: 3.12.3

When I try to use the tb-rest client 3.8.0 (pip installed) on from a python script like this:

try:
    from tb_rest_client.rest_client_ce import RestClientCE
    from tb_rest_client.models.models_ce import EntityId
    from tb_rest_client.rest import ApiException
except ImportError as exc:
    print(f"ERROR: Missing dependency. {exc}\n")
    sys.exit(1)

I got this error:

ERROR: Missing dependency. No module named 'six.moves'

A workaround is to do

pip uninstall six // this uninstalls version 1.10
pip install six==1.17.0 // this gives a warning (because tb-rest-client expects 1.10)

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. 
This behaviour is the source of the following dependency conflicts.
tb-rest-client 3.8.0 requires six==1.10, but you have six 1.17.0 which is incompatible.
Successfully installed six-1.17.0

But then the script works. six 1.10 Works okay on Ubuntu Linux 22.04-LTS.

rretanubun avatar Dec 24 '24 14:12 rretanubun

Fails in the same way with Ubuntu 24.04.x, with the same workaround (force six==1.17.0), but this degrades tb-rest-client down to v3.7.0 (from 3.9.0)

I don't know anything about Python project packaging, but the problem seems to be that in the change from 'setup.py' to 'pyproject.toml' (commit 1340f272dd93b486ab596bc0c42c6302f9ec10c3), the dependencies changed from '>=' to '=='.

tb-rest-client v3.7.0, setup.py:

install_requires=[
        'certifi >= 2023.7.22',
        'six >= 1.10',
        'python_dateutil >= 2.5.3',
        'setuptools >= 21.0.0',
        'urllib3 >= 2.0.7',
        'requests>=2.31.0',
        'pyjwt==2.6.0',
]

tb-rest-client v3.9.0, setup.py has gone, but pyproject.toml contains

[tool.poetry.dependencies]
python = "^3.9"
certifi = "2023.7.22"
six = "1.10"
python_dateutil = "2.5.3"
setuptools = "21.0.0"
urllib3 = "2.0.7"
requests = "2.31.0"
pyjwt = "2.6.0"

I am not set up to build Python packages, so I cannot create a pull request.

ironss-iotec avatar Feb 23 '25 04:02 ironss-iotec

OS: Ubuntu 22.04 Python version: 3.12.3 tb-rest client 3.9.0

Hello, I have the same issue. Fixed with the same suggestion. The pyproject.toml file is not aligned with the requirements.txt. Could someone adjust the pyproject.toml? I think it should be as below

[tool.poetry.dependencies]
python = "^3.9"
certifi = "^2023.7.22"
six = "^1.10"
python_dateutil = "^2.5.3"
setuptools = "^21.0.0"
urllib3 = "^2.0.7"
requests = "^2.31.0"
pyjwt = "2.6.0"

tscu-vid avatar Mar 05 '25 17:03 tscu-vid

I have encountered the same problem, as the module published on pipy is probably built on pyproject.toml and it has the versions of its dependencies fixed (==) which is different from dependency definition in requirements.txt.

@samson0v @imbeacon is there any progress on this?

wendl4 avatar Mar 12 '25 19:03 wendl4

My suggestion (mirroring requirements.txt for poetry dependencies)

[tool.poetry.dependencies]
python = ">=3.9"
certifi = ">=2023.7.22"
six = ">=1.10"
python_dateutil = ">=2.5.3"
setuptools = ">=21.0.0"
urllib3 = ">=2.0.7"
requests = ">=2.31.0"
pyjwt = "2.6.0"

because if we use ^, it has the major version fixed and therefore is different from >= which is used for these versions in the requirements.txt

wendl4 avatar Mar 13 '25 14:03 wendl4

thank you @imbeacon for merging the proposed changes in this PR. Now we just need to wait for the new version release.

wendl4 avatar Mar 20 '25 15:03 wendl4

Hello @samson0v, @imbeacon. Do you plan to make a new release with the changes merged in the PR mentioned above? I am using the forked version now for more than month for our project but would like to stay with the original package and I think there are also other people who would appreciate it. Thanks!

wendl4 avatar Apr 09 '25 12:04 wendl4

Hi @wendl4, the new release with these changes will come soon.

samson0v avatar Apr 17 '25 07:04 samson0v