-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?
-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?
Browser other questions tagged python visual-studio-code pycharm
You are not signed in. Login or sign up in order to post.
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.
– Woss
(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.
– Woss
there is something that can be done within vscode for the execution to occur?
– guilhermeaquinop
The correct question is: what can I do to not depend on this execution?
– Woss
if you know and can explain, I appreciate
– guilhermeaquinop
For this we need you to add in the question the structure of folders and files you are using.
– Woss
is added
– guilhermeaquinop
And in which file is the code that went wrong?
– Woss
the error is in main.py
– guilhermeaquinop
If I understand correctly,
main.py
is also in the folderfiles/lib
, then the import will only be of files.from arquivos import *
– Woss
no, main.py is in the file folder'
– guilhermeaquinop
So it is
from lib.arquivos
– Woss
well, this error came out and two others appeared involving opening the files. txt I can fix, but soon after a similar
– guilhermeaquinop
Modulenotfounderror: No module named 'lib'
– guilhermeaquinop
In another file, I bet
– Woss
so I was thinking it was something related to vscode, the error goes from file to file
– guilhermeaquinop
tried to run without folder files, and generated that same error
– guilhermeaquinop
Then I recommend you to study again the Python import system. Surely you missed several details about the operation.
– Woss
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
– guilhermeaquinop
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.
– Woss