Modulenotfounderror: No module named 'files'

Asked

Viewed 37 times

-1

I was using Pycharm in the elaboration of my project and everything was going well. I migrated to Vscode and this problem appeared, and there were no changes to the code. There is something specific to be done in Vscode?inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • Yes, spells that Pycharm does for you without you knowing. He adapts the Import Path adding your project directory and so some imports that work on it do not work on other editors. This makes it easier sometimes, but if it depends on it to work, I recommend reviewing how you organized the project.

  • (Mr. M) Magic that Pycharm does: https://i.stack.Imgur.com/4UAoh.png. When you click to run it inserts this at the beginning of the file.

  • there is something that can be done within vscode for the execution to occur?

  • The correct question is: what can I do to not depend on this execution?

  • if you know and can explain, I appreciate

  • For this we need you to add in the question the structure of folders and files you are using.

  • is added

  • And in which file is the code that went wrong?

  • 1

    the error is in main.py

  • If I understand correctly, main.py is also in the folder files/lib, then the import will only be of files. from arquivos import *

  • 1

    no, main.py is in the file folder'

  • 1

    So it is from lib.arquivos

  • well, this error came out and two others appeared involving opening the files. txt I can fix, but soon after a similar

  • Modulenotfounderror: No module named 'lib'

  • In another file, I bet

  • so I was thinking it was something related to vscode, the error goes from file to file

  • tried to run without folder files, and generated that same error

  • Then I recommend you to study again the Python import system. Surely you missed several details about the operation.

  • I’ll take a look again, but I still find it hard to be an import error. The same folder structure was used in Pycharm and there was no error. If you want to take a look at the code, follow the repository: link

  • It’s an import error. It works on Pycharm because of the magic he does that I’ve already mentioned here. Keep in mind that the import path should be relative to your application’s input file, i.e., main.py.

Show 15 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.