Reputation: 111
I've tried importing boto3 in python3 it's working, but i've tried boto3 in python2.7, it is throwing following error.
python3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
>>> import boto3
>>> exit()
$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
>>> import boto3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named boto3
How we can make boto3 to work with python2.7 ?
Upvotes: 4
Views: 21691
Reputation: 181
As answered already pip install boto3 will resolve this error. I would suggest using one version of Python (either 3 or 2) for your application. Even if the OS relies on python2, your application can make use of python3. Anyways, python2 EOL is 2020 - so python2 will slowly diminish.
Upvotes: 0
Reputation: 111
I've created new virtual env and activated it. It is working good in New virtual env.
virtualenv path/to/my/virtual-env
source path/to/my/virtual-env/bin/activate
Upvotes: -1
Reputation: 925
Notice that packages are not shared between python versions. If you install a package in your python3.x local version, it doesn't mean the package will be installed in your python2.x local version...
First of all do the following:
pip freeze
If boto3 package isn't there, great! install it:
pip install boto3
if it is there then verify what pip is being used and make sure to use the pip linking to your python2.x version:
which pip
you can create a symlink to use pip for python2.7... or even better, use pyenv to manage your python versions and virtualenv to isolate your workspace for a given python version.
https://virtualenv.pypa.io/en/stable/
Upvotes: 4