Unable to install boto3
Asked Answered
W

16

87

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
'2.38.0'

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?

Windowshop answered 28/10, 2015 at 10:27 Comment(2)
Are you using python2.7?Mantua
Updating pip fix my problem python -m pip install --upgrade pip :)Preferment
E
69

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.

Erde answered 28/10, 2015 at 10:31 Comment(3)
Awesome, timely and perfect. Thank you very much. I will accept this as answer in 7 minutes.Windowshop
fwiw using sudo on any install process is going to give you a headache. I recommend doing any installs without sudoEfflorescent
This worked for me. It doesn't work if you are trying to install it only on your virtual environmentGlobeflower
P
105

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.

Ploughshare answered 2/8, 2016 at 19:46 Comment(2)
Thanks, worked for me. I was having both 2.7 and 3.4 versions.Robbi
This is working great on Python2.7 and Python3.6 both.Cohabit
E
69

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.

Erde answered 28/10, 2015 at 10:31 Comment(3)
Awesome, timely and perfect. Thank you very much. I will accept this as answer in 7 minutes.Windowshop
fwiw using sudo on any install process is going to give you a headache. I recommend doing any installs without sudoEfflorescent
This worked for me. It doesn't work if you are trying to install it only on your virtual environmentGlobeflower
D
54

try this way:

python -m pip install --user boto3
Debi answered 18/7, 2018 at 23:53 Comment(3)
This is the only solution that worked for me. Without virtual envs, without changing anything in my setup.Thiouracil
It was also the only solution for me on Ubuntu 16.04.5 LTS with Python 3.5.2 + Python 2.7.12Rhodos
for macOS [~Oct2020] using python3 instead of python for this answer worked for me.Sunnysunproof
E
22

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.

Earhart answered 22/3, 2017 at 0:19 Comment(0)
V
16

For Python 3

python3 -m pip install --user boto3

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

Valletta answered 2/3, 2021 at 10:5 Comment(0)
P
15

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

easy_install boto3
Peshitta answered 12/5, 2017 at 10:40 Comment(3)
I am using Ubuntu 16.04 and my python version is 2.7Peshitta
"sudo easy_install boto3" worked for me on Ubuntu 16Gobbledygook
this worked for me. because pip would install boto3 only for python3.Musca
C
3

Activate virtual environment and run following command:

pip install boto3

for Windows user

Compatriot answered 11/5, 2021 at 18:26 Comment(0)
P
1

Do not run as sudo, just type:

pip3 install boto3==1.7.40 --user

Enjoy

Prunelle answered 22/6, 2018 at 22:39 Comment(0)
D
1

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!

Db answered 1/4, 2021 at 20:35 Comment(0)
S
0

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
Sax answered 9/3, 2021 at 7:34 Comment(0)
L
0

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

Layamon answered 28/12, 2021 at 6:24 Comment(0)
M
0

In VScode terminal, Sudo is not required. pip install boto3 will install boto3

Margertmargery answered 2/11, 2023 at 15:23 Comment(0)
A
-1

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.

Anticlastic answered 4/11, 2019 at 0:21 Comment(0)
O
-1

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
Outroar answered 7/5, 2022 at 21:5 Comment(1)
not all developers use Pycharm, so a better solution is indicate general instructions like pip install boto3 in the virtual enviroment.Tasso
H
-1

I had the same issue and it turned out that boto3 wasn't installed in the same directory as my python interpreter. It's worth it to check that if all the solutions above don't work for you.

Hocus answered 8/11, 2023 at 11:55 Comment(1)
Please be sure to either convert this post into a comment or to turn it into a qualified answer (see How to Answer for guidance)Shavonda
C
-3

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

Currish answered 25/1, 2019 at 2:52 Comment(1)
See Leistungsabfall's answer.Uncivilized

© 2022 - 2024 — McMap. All rights reserved.