module 'lazr' breaks pydeps
Closed this issue · 6 comments
Tested on Linux, Ubuntu 20.04.
Consider this oneliner test program test_pydeps.py
:
import lazr
Run pydeps on it. It will give an enormous stacktrace, this is the tail:
File "/home/jan/.local/lib/python3.8/site-packages/pydeps/py2depgraph.py", line 139, in import_module
module = mf27.ModuleFinder.import_module(self, partnam, fqname, parent)
File "/usr/lib/python3.8/modulefinder.py", line 318, in import_module
fp, pathname, stuff = self.find_module(partname,
File "/usr/lib/python3.8/modulefinder.py", line 510, in find_module
return _find_module(name, path)
File "/usr/lib/python3.8/modulefinder.py", line 79, in _find_module
if spec.loader.is_package(name):
AttributeError: 'NoneType' object has no attribute 'is_package'
Excepted result: a more descriptive error or warning, mentioning lazr
, perhaps guiding the user to exclude it?
I ran into this problem when I tried to analyze my own project. Had to sprinkle some print statements in pydeps to figure out that lazr
was the problem.
Workaround which works fine for me: just exclude lazr
.
PS: I have no clue what lazr
is, how it found its way onto my system, and why it is so special for pydeps; I just happen to implicitly use it in my project.
Which version of pydeps (pydeps --version
) are you running, and which Python version (python -V
)? Running pydeps test_pydeps.py
in a fresh virtualenv gives me an empty svg and no traceback (Python 3.6/3.8, pydeps v1.10.14).
pydeps v1.10.14
Python 3.8.10
edit: if you still cannot reproduce, which seems likely at this point, then I could attempt some more digging on my end
Not ubuntu, but...
(pydeps140) go|c:\srv> python -V
Python 3.8.10
(pydeps140) go|c:\srv> pip install pydeps
Collecting pydeps
Using cached pydeps-1.10.14-py3-none-any.whl (38 kB)
Collecting stdlib-list
Using cached stdlib_list-0.8.0-py3-none-any.whl (63 kB)
Installing collected packages: stdlib-list, pydeps
Successfully installed pydeps-1.10.14 stdlib-list-0.8.0
(pydeps140) go|c:\srv> pydeps --version
pydeps v1.10.14
(pydeps140) go|c:\srv> cd tmp\pydeps140
(pydeps140) go|c:\srv\tmp\pydeps140> cat test_pydeps.py
import lazr
(pydeps140) go|c:\srv\tmp\pydeps140> pydeps test_pydeps.py
(pydeps140) go|c:\srv\tmp\pydeps140> ll
total 16
-rw-rw-rw- 1 bp 0 0 2022-04-19 11:29 __init__.py
-rw-rw-rw- 1 bp 0 631 2022-04-20 11:28 pydeps140_test_pydeps.svg
-rw-rw-rw- 1 bp 0 13 2022-04-19 11:28 test_pydeps.py
and an empty .svg.
If I add the --include-missing
flag:
(pydeps140) go|c:\srv\tmp\pydeps140> pydeps test_pydeps.py --include-missing
(pydeps140) go|c:\srv\tmp\pydeps140>
I get the following graph:
This should be fixed in the latest version (v1.10.17) available on PyPI.
Solved indeed, many thanks!