Almenon / AREPL-vscode

Program python in real-time
MIT License
261 stars 30 forks source link

ModuleNotFoundError: No module named arepl_dump #379

Open eliassal opened 3 years ago

eliassal commented 3 years ago

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):

Almenon commented 3 years ago

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

Almenon commented 3 years ago

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 🤔

eliassal commented 3 years ago

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

Almenon commented 3 years ago

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.

vbrozik commented 2 years ago

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
eliassal commented 2 years ago

@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

vbrozik commented 2 years ago

@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.

bernhardkaindl commented 2 years ago

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