Import "boto3" could not be resolved/Python, VS Code
Asked Answered
C

6

21

I am working on my python project, wherefor I need to import the package called "boto3". Therefore I get this error tooltip: "Import "boto3" could not be resolved". I tried out "pip install boto3" in the VS code terminal and reloaded the window but still the error tooltip does not go away :/

What am I doing wrong? Thanks in advance

Corroborant answered 28/1, 2021 at 8:34 Comment(2)
Any info about your operation system? Where and how exactly did you install boto3? What is your python version?Noella
I opened the terminal and just placed "pip install boto3" in the path, which was pre-defined; My python is 3.9.1 and I am on a WIN10Corroborant
S
33

Check to ensure vs code is using the correct Python interpreter. You can do this by opening up the command palette (Ctrl+Shift+P), and search "Python: Select Interpreter". Here is a screenshot of what my visual studio code looks like when I go to select the Python interpreter I need at the time.

vscode python select interpreter

For more information, here is some useful documentation:

Shadwell answered 28/1, 2021 at 23:32 Comment(3)
import boto3 ModuleNotFoundError: No module named 'boto3' --> that is the message I get. Maybe I am doing the "pip install boto3" on the wrong path? I am just taking the path which is being displayed by VS COde in the terminal but maybe that is wrong oneCorroborant
Since changing your python interpreter in vs code, have you tried to run pip3 install boto3 in the vs code terminal?Shadwell
I had to close vscode after choosing the the right interpreter and did pip3 install boto3 once more, it printed out requirement already satisfied and that boto3 and botocore were already installed in /home/<user_name>/.local/lib/python3.8/site-packages. Seems like pylance for vscode already reads site-packages so I just needed to refresh vscode to make that modulenotfound message dissapearXenophobe
L
9

I had the same issue on VS Code.

To solve it, I did these steps:

  1. Install pip, sudo apt install python3-pip
  2. Install boto3, pip install boto3
  3. Restart VS Code
Lacedaemon answered 26/10, 2021 at 14:15 Comment(0)
L
2

I had the same issue, and I've resolved it:

  • Go to Command Palette in VS Code using Ctrl+Shift+P, Select Python Interpreter.
  • Then select the second version. In my case Python version 3.10.8 64-bit not working
  • Using now Python version 3.10.8 64-bit
  • Restart VScode, and ENJOY 🥳
Longplaying answered 22/12, 2022 at 8:7 Comment(1)
'Restart VScode' was the hot tip.Halicarnassus
O
1

I solved the error by changing the Python Interpreter. In my case, the default python was Python 3.8.10, but the Python Interpreter in VS Code was Python 3.9.7. To resolved the issue I used the following steps:

  1. In the terminal, find out the default python version using python3 --version or python3 -V

  2. Go to Command Palette in VS Code using Ctrl+Shift+P, select Python Interpreter.

  3. Change the Python Interpreter to the default version.

  4. Restart the VS Code.

I hope this helps.

Oldham answered 11/10, 2022 at 6:29 Comment(0)
V
-1

in vscode Problems tab it was yet showing errors like this

Import "common.sql_db_engine" could not be resolved

I had execute this command

pip install -r requirements.txt

but yet the imports were not resolved... I restarted vscode and it worked

Vanward answered 3/2, 2022 at 8:11 Comment(0)
U
-4
pip3 install boto3

Execute this command in terminal window. This helped me in solving the issue.

Ung answered 19/10, 2021 at 14:7 Comment(4)
Well, this "solution" was already mentioned in the question but did not help. So it's not an answer to this question.Pudding
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Eva
@Pudding the OP mentions pip install boto3, is that the same as pip3 install boto3? I am unfamiliar with Python, but just checking that they aren't actually different things.Vermiculation
@Dylan_Gomes, good catch! I don't suspect this makes the difference in this case, but it certainly is possible. It would have been nice if this difference was made more clear in the answer instead of only mentioning the command. (Which is probably why the review comment about improving the question was made...)Pudding

© 2022 - 2024 — McMap. All rights reserved.