AREPL-vscode icon indicating copy to clipboard operation
AREPL-vscode copied to clipboard

ModuleNotFoundError: No module named arepl_dump

Open eliassal opened this issue 4 years ago • 8 comments
trafficstars

Describe the bug I copied the code for Misc/Dumping, once pasted, VSC puts a red suiggly line under "arepl_dump" in from arepl_dump import dump I hit run without debug, I get variables dumped on the right hand side but in terminal I get

File "c:\Projects\Python\10 Py Apps10Days\dumpallvar.py", line 1, in from arepl_dump import dump ModuleNotFoundError: No module named 'arepl_dump'

To Reproduce Steps to reproduce the behavior:

  1. Described above

Expected behavior it should work according to what is mentioned at https://marketplace.visualstudio.com/items?itemName=almenon.arepl

Screenshots AREPL-VSC

Other Information (please complete the following information):

  • OS: Windows10 64bit
  • Python Version 3.9

eliassal avatar Mar 25 '21 11:03 eliassal

arepl_dump is not meant to be run from the command line - it only works in AREPL.

Almenon avatar Mar 26 '21 06:03 Almenon

That being said it would probably still be good to have it not cause an error when running from the command line, so users can run a script from the shell without having to comment the import out 🤔

Almenon avatar Mar 26 '21 06:03 Almenon

Yes, good idea is not to generate the suiglly red line and leave us run commands without errors. Can this be fixed?

eliassal avatar Mar 26 '21 07:03 eliassal

It can, but I don't work that much on this project anymore. You or someone else is welcome to be submit a PR if you wish.

Almenon avatar Mar 27 '21 23:03 Almenon

It would be great to get rid of the reported problem. For example if Pylance is being used (I think it is the default in VS Code) it shows the red underline and this message in the problems report:

Import "arepl_dump" could not be resolved

Of course constantly reported problems make the otherwise extremely useful problem report hard to use.

For Pylance a simple workaround could be to ignore the problem by appending a directive:

from arepl_dump import dump     # type: ignore

vbrozik avatar Dec 01 '21 09:12 vbrozik

@vbrozik , not sure what you suggest resolves the issue. I have the directive, when I hit the button run in VSCode, still getting

ModuleNotFoundError: No module named 'arepl_dump',

as you can notice in the snapshot

arepl-Dump

eliassal avatar Dec 01 '21 11:12 eliassal

@eliassal, I was reacting just to:

good idea is not to generate the suiglly red line

Of course the directive just deactivates the Pyright/Pylance check (inside VS Code) to get rid of the red line. It will not make the code run outside of AREPL.

vbrozik avatar Dec 01 '21 15:12 vbrozik

I've had this error even inside vscode, at least when using a venv. For this and the case when run outside of vscode, this ìmport appears to help (yes, the finallyseems to be needed as well, otherwise I get a new editor with these lines in it as an Unitled file an of course arepl does not work then:

try:
    from arepl_dump import dump  # type: ignore
except ModuleNotFoundError:
    def dump() -> None:
        return
finally:
    pass

bernhardkaindl avatar Mar 24 '22 23:03 bernhardkaindl