Unable to install boto3


Python Problem Overview

I have trouble installing boto3 inside a virtual environment.

I have done what the document says. First I activated virtual environment. then I did a:

Sudo pip install boto3

Now I enter python

>> import boto3
ImportError: No module named boto3

But if I import boto, it works

>> import boto
>> boto.Version

Why does it install boto 2.38 when I installed boto3. I tried closing the terminal and re-opened it. Should I restart the Ubuntu machine?

Python Solutions

Solution 1 - Python

There is another possible scenario that might get some people as well (if you have python and python3 on your system):

pip3 install boto3

Note the use of pip3 indicates the use of Python 3's pip installation vs just pip which indicates the use of Python 2's.

Solution 2 - Python

Don't use sudo in a virtual environment because it ignores the environment's variables and therefore sudo pip refers to your global pip installation.

So with your environment activated, rerun pip install boto3 but without sudo.

Solution 3 - Python

try this way:

python -m pip install --user boto3

Solution 4 - Python

I had a similar problem, but the accepted answer did not resolve it - I was not using a virtual environment. This is what I had to do:

sudo python -m pip install boto3

I do not know why this behaved differently from sudo pip install boto3.

Solution 5 - Python

I have faced the same issue and also not using virtual environment. easy_install is working for me.

easy_install boto3

Solution 6 - Python

For Python 3

python3 -m pip install --user boto3

Source: https://github.com/boto/boto/issues/3194#issuecomment-668420011

Solution 7 - Python

Activate virtual environment and run following command:

pip install boto3

for Windows user

Solution 8 - Python

Do not run as sudo, just type:

pip3 install boto3==1.7.40 --user


Solution 9 - Python

I figured it out. This will work for VSCode:

  1. Install the Python extension for VSCode

  2. Create new folder and add a python script in it

  3. Install venv and activate inside VSCode Console in your project:

    python3 -m venv venv source ./venv/bin/activate (venv) My-MacBook-Air:python-scripts user$

Notice venv is activated: (venv)

  1. Install boto3 inside the activated venv environment:

    pip3 install boto3

  2. Check your venv/lib/python3.9/site-packages folder to confirm boto3 is in there.

  1. Press CMD + Shift + P and set the python interpret to ./venv/bin/python. Note you may also need to press "CMD ,", enter "python.pythonPath" and set the Python Path appropriately.

Then it will work for sure!

Solution 10 - Python

I have the similar issue. In my system Anaconda distribution is installed. While running my python program in the Juypyter notebook, it was showing

no module named 'boto3'

While checking in command prompt

>pip install boto3

Requirement already satisfied.

Inorder to resolve the same for Juypyter notebook, open "Anaconda Prompt" and

install Boto3 using

pip install boto3

Solution 11 - Python

Try this. I was facing the same issue on windows and I resolved by following the below steps.

  1. >>> exit() - exist python

    enter image description here

  2. pip3 install boto3 - execute this command

    enter image description here

Solution 12 - Python

Though this is an old post, I am posting how I resolved in case it helps others. Since I used sudo to do the install of the boto3 library the permissions on the boto3 directory was set to 700. Either change the permissions to be readable by others or run the python command as sudo.

Solution 13 - Python

In Pycharm

Press Ctr + Alt + s
 On left, Project <your project here> > Project Interpreter
  On right, click on +
  At the top, search for boto3
  At the bottom, click on Install Package

Solution 14 - Python

Try this it works sudo apt install python-pip pip install boto3


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPrabhakar ShanmugamView Question on Stackoverflow
Solution 1 - PythonCasualTView Answer on Stackoverflow
Solution 2 - PythonLeistungsabfallView Answer on Stackoverflow
Solution 3 - PythonTushar NirasView Answer on Stackoverflow
Solution 4 - PythonschmittView Answer on Stackoverflow
Solution 5 - Pythonsib10View Answer on Stackoverflow
Solution 6 - PythonJerry ChongView Answer on Stackoverflow
Solution 7 - PythonAbdullah RafiView Answer on Stackoverflow
Solution 8 - PythonPaulo VictorView Answer on Stackoverflow
Solution 9 - PythonDaniel ViglioneView Answer on Stackoverflow
Solution 10 - PythonBigData-GuruView Answer on Stackoverflow
Solution 11 - PythonGanesa VijayakumarView Answer on Stackoverflow
Solution 12 - PythonnmakbView Answer on Stackoverflow
Solution 13 - PythonpwkcView Answer on Stackoverflow
Solution 14 - Pythonuser10965163View Answer on Stackoverflow