pip-check-reqs
pip-check-reqs copied to clipboard
DeprecationWarning: the imp module is deprecated in favour of importlib
Using imp.find_module doesn't work on all my installed pip-packages. Now it fails on the azure-iot-hub module.
For example:
In [7]: imp.find_module("azure")
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-c3ad326176a9> in <module>
----> 1 imp.find_module("azure")
~/dev/work/projects/python-iot-common/venv/lib/python3.6/imp.py in find_module(name, path)
295 break # Break out of outer loop when breaking out of inner loop.
296 else:
--> 297 raise ImportError(_ERR_MSG.format(name), name=name)
298
299 encoding = None
ImportError: No module named 'azure'
But it does work with the favour one "importlib".
In [10]: importlib.util.find_spec("azure")
Out[10]: ModuleSpec(name='azure', loader=None, origin='namespace', submodule_search_locations=_NamespacePath(['/home/knest/dev/work/projects/python-iot-common/venv/lib/python3.6/site-packages/azure']))
And thats why "find_extra_reqs" thinks the module is not installed, but it is... Deprecated since version 3.4 https://docs.python.org/3/library/imp.html
Thanks for the bug report @robbinvandamme . Are you up for submitting a PR?
@adamtheturtle is there a developer guide or something like that? I ran the tests without any changes after installing the requirements in a venv but some tests are failing, so i think i'm just using is the wrong way.
I only recently started on one at https://github.com/r1chardj0n3s/pip-check-reqs/blob/master/CONTRIBUTING.rst but that is not comprehensive. Perhaps you could make a bug report for your test failures and we can go from there?
@adamtheturtle shouldn't the tests on the master be passing? It seems a bit strange to submit a bug report for my failing test if its caused by my dev environment. What should i do to run the test?
- create venv
- install requirements and test-requirements
- run pytest ./* in the test folder
Or am i missing something?
@robbinvandamme That works for me and tests pass on CI.
@adamtheturtle what python version to you use?
@robbinvandamme I'm using Python 3.9.2 with pip 21.0.1. If you can create a bug report for the failing tests we can go from there and have a dedicated place to discuss the tests failing for you locally.
@adamtheturtle I started all over again with clean venv and now all tests seem to pass. Don't now what was wrong before. next to steps above i also did python3 setup.py install (in the previous venv i probably ran the tests after running the install with already some changes to common.py)
I'll try to find some time and submit a pull request somewhere in the next days.
Sorry @adamtheturtle, I won't be submitting a pull request.
This is now done.