1

I want to get boto3 working in a python3 script. I can execute aws commands from the cli.

  1. After updating pip, it doesn't run with sudo rights unless I use the absolute path: /usr/local/bin/pip. Without sudo rights it works. I have no idea why it doesn't run under sudo, which it did before updating, as /usr/local/bin is in PATH.

  2. Should I run pip under sudo or not?

  3. I installed boto3, but still get ImportError: No module named 'boto3'. This is when I execute a script that runs python3. But it seems that boto3 is installed for python2.

Output:

$ sudo /usr/local/bin/pip install --upgrade boto3
Requirement already up-to-date: boto3 in /usr/local/lib/python2.7/site-packages

How do I get boto3 working with python3?

SPRBRN
  • 561
  • 4
  • 12
  • 27

3 Answers3

1

Probably, the best way to deal with multiple python versions is to isolate them using virtualenv

This article covers it's basics and would give you a good overview http://docs.python-guide.org/en/latest/dev/virtualenvs/

  • Thanks. That fixes question 3. I still have to use the absolute path for pip, but that's not a major problem. And I'm still wondering whether to run pip as root or not. – SPRBRN Jan 08 '16 at 11:44
  • virtualenv by default lets you run it as regular user, as it installs packages inside an env and accessible for your current user – Serhii Balbieko Jan 08 '16 at 11:48
0

If you're using ubuntu, try this out:-

sudo apt install python-boto3

Should work.

Vinu Joseph
  • 105
  • 1
-1
brew postinstall python3

worked after a 'brew upgrade' caused this error to come up.

tkjef
  • 369
  • 3
  • 6