Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'zipimporter' object has no attribute 'path' #43

Closed
amendlik opened this issue Nov 5, 2020 · 16 comments
Closed

AttributeError: 'zipimporter' object has no attribute 'path' #43

amendlik opened this issue Nov 5, 2020 · 16 comments
Assignees

Comments

@amendlik
Copy link

amendlik commented Nov 5, 2020

Pylint is failing with a stack trace:

Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pylint.exe\__main__.py", line 7, in <module>
  File "c:\python38\lib\site-packages\pylint\__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "c:\python38\lib\site-packages\pylint\lint\run.py", line 308, in __init__
    linter.load_plugin_modules(plugins)
  File "c:\python38\lib\site-packages\pylint\lint\pylinter.py", line 490, in load_plugin_modules
    module = modutils.load_module_from_name(modname)
  File "c:\python38\lib\site-packages\astroid\modutils.py", line 203, in load_module_from_name
    return load_module_from_modpath(dotted_name.split("."), path, use_sys)
  File "c:\python38\lib\site-packages\astroid\modutils.py", line 245, in load_module_from_modpath
    module = imp.load_module(curname, mp_file, mp_filename, mp_desc)
  File "c:\python38\lib\imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "c:\python38\lib\imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 50, in <module>
    class ThirdPartyImportsChecker(BaseChecker):
  File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 72, in ThirdPartyImportsChecker
    all_modules = {m[1]: m[0].path for m in pkgutil.iter_modules()}
  File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 72, in <dictcomp>
    all_modules = {m[1]: m[0].path for m in pkgutil.iter_modules()}
AttributeError: 'zipimporter' object has no attribute 'path'
@amendlik
Copy link
Author

@s0undt3ch Any advice on how to proceed on this issue?

@amendlik
Copy link
Author

@s0undt3ch Still looking for guidance on this issue.

@amendlik
Copy link
Author

amendlik commented Feb 1, 2021

@s0undt3ch This seems to be a Windows-specific issue. Any thoughts?

@gmrichmond
Copy link

@twangboy: Given the last comment, is this something you could provide insight into?

@xeacott
Copy link

xeacott commented Feb 12, 2021

So what machine is this coming from? Is that your pylint from a local run?

@amendlik
Copy link
Author

Yes, this is from running PyLint on my local Windows workstation.

@xeacott
Copy link

xeacott commented Feb 15, 2021

Im not sure how related it is, but I suppose a few things along with the info in the traceback;

We currently support 3.8 for Window's, however we run tests against 3.7 and I personally use 3.6 for many other compatibility issues, so potentially trying another version of Python, which can be pretty quick on Windows. Also, I read through the traceback and it doesn't appear to be going into any Salt code.

Was this pylint you're running from our ci pre-commit stuff? Or anything related to salt?

@amendlik
Copy link
Author

I have also tested this with Python 3.6 and got the same result.

This is not an error with Salt product, it is an error with the salt-pylint (this repository). The Salt product code includes a .pylintrc that loads saltpylint as a plugin and that is the code that is failing. You can see the last few items in the call stack are within saltpylint:

File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 50, in <module>
    class ThirdPartyImportsChecker(BaseChecker):
File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 72, in ThirdPartyImportsChecker
    all_modules = {m[1]: m[0].path for m in pkgutil.iter_modules()}
File "c:\python38\lib\site-packages\saltpylint\thirdparty.py", line 72, in <dictcomp>
    all_modules = {m[1]: m[0].path for m in pkgutil.iter_modules()}

@xeacott
Copy link

xeacott commented Feb 15, 2021

🤦 of course, apologies. Was too quick to not notice the repo it was pulled under. Okay, with that being said - let me pull this repo down, give it a go and see what I can tinker with.

@amendlik
Copy link
Author

@xeacott Any update on this?

1 similar comment
@amendlik
Copy link
Author

@xeacott Any update on this?

@xeacott
Copy link

xeacott commented Mar 12, 2021

Yes! No excuse for not getting back earlier. So I've reproduced this on window's as well as have a fix. I've tested on Ubuntu that is isn't breaking anything either. But before I can consider it fixed I need ask Pedro if the fix is correct.

C:\dev\salt\salt\modules (master_modifications_minion -> origin)
λ pylint win_wua.py
************* Module win_wua
win_wua.py:56: [C0328(unexpected-line-ending-format), ] Unexpected line ending format. There is 'CRLF' while it should be 'LF'.
.
.
.
win_wua.py:1109: [C0328(unexpected-line-ending-format), ] Unexpected line ending format. There is 'CRLF' while it should be 'LF'.
------------------------------------
Your code has been rated at -1.41/10

@xeacott
Copy link

xeacott commented Mar 12, 2021

In fact, let me open a PR with the change (its just removing the .path call) and we can take the conversation there.

@s0undt3ch
Copy link
Contributor

This was fixed by #44

@I3urny
Copy link

I3urny commented Aug 2, 2023

@s0undt3ch is this change already included in the saltstack/salt repo? I dont think it is.
I'm developing on windows and just came across this problem.

If I'm not mistaken the saltpylint version to be used in saltstack/salt is defined in https://github.com/saltstack/salt/blob/29743902636fcc2b57d67e9e8dde180c550d49f2/requirements/static/ci/lint.in#L1-L6

Since this fix was added after the v2020.9.28 release the error still occurs on windows. Could you bump the version and update the reference in the saltstack/salt repo?

@s0undt3ch
Copy link
Contributor

@I3urny saltstack/salt#64919

Thank you for the reminder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants