Problems with the vscode interpreter

Asked

Viewed 579 times

1

inserir a descrição da imagem aqui

Well, the Code works, I changed the vscode interpreter that was in global python 3.7 from Ubuntu even to virtualenv python, the code works, but I do not understand why this error in Problems. I’m importing right, and the code runs.

inserir a descrição da imagem aqui

As seen in the second image, by dotting after from and before dir, the error disappears, but the code when running presents this error: Traceback (Most recent call last): File "index.py", line 1, in from .Twitter.searchTweets import Twitter Modulenotfounderror: No module named 'main.Twitter'; 'main' is not a package

Unfortunately I’m not getting this kind of problem.

1 answer

1


When an import is done using.name ' is a relative import, which only works if the "parent module" (Parent module) is imported together.

Example:

`from Twitter.searchTweets`

You are importing the searchTweets which is relative to Twitter, so putting the point before Twitter (.Twitter.searchTweets) you are saying that Twitter is relative to another parent module.

So, the first image presents the right syntax, but it presents an import error that is caused precisely by the integer as you said, when I use Vscode in Ubuntu I usually run the code in a separate terminal where I can configure the environments more easily, avoiding errors with IDE’s, probably not the healthiest practice, but it is a solution.

Browser other questions tagged

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