Reputation: 6154
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?
Upvotes: 89
Views: 312106
Reputation: 15
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.
Upvotes: -1
Reputation: 9
In VScode terminal, Sudo is not required. pip install boto3 will install boto3
Upvotes: 0
Reputation: 11
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
Upvotes: 0
Reputation: 2602
Try this. I was facing the same issue on windows and I resolved by following the below steps.
Upvotes: 0
Reputation: 49
Activate virtual environment and run following command:
pip install boto3
for Windows user
Upvotes: 3
Reputation: 9477
I figured it out. This will work for VSCode:
Install the Python extension for VSCode
Create new folder and add a python script in it
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)
Install boto3 inside the activated venv environment:
pip3 install boto3
Check your venv/lib/python3.9/site-packages folder to confirm boto3 is in there.
Then it will work for sure!
Upvotes: 1
Reputation: 1261
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
Upvotes: 0
Reputation: 9240
For Python 3
python3 -m pip install --user boto3
Source: https://github.com/boto/boto/issues/3194#issuecomment-668420011
Upvotes: 17
Reputation: 5049
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.
Upvotes: 107
Reputation: 1245
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.
Upvotes: -2
Reputation: 5
Try this it works sudo apt install python-pip pip install boto3
Upvotes: -4
Reputation: 4122
Do not run as sudo, just type:
pip3 install boto3==1.7.40 --user
Enjoy
Upvotes: 1
Reputation: 1182
I have faced the same issue and also not using virtual environment. easy_install is working for me.
easy_install boto3
Upvotes: 15
Reputation: 347
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
.
Upvotes: 22
Reputation: 6488
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.
Upvotes: 69