Thursday, August 2, 2018

ImportError: No module named botocore.session - Solved

My aws cli had some installation problems and ended up using the following error


$ aws

Traceback (most recent call last):

  File "/usr/bin/aws", line 19, in <module>

    import awscli.clidriver

  File "/usr/lib/python2.7/site-packages/awscli/clidriver.py", line 17, in <module>

    import botocore.session

ImportError: No module named botocore.session

Running the following command fixed the problem:


$ sudo pip install awscli --force-reinstall --upgrade

Collecting awscli

  Using cached https://files.pythonhosted.org/packages/18/99/a1a1ea5a91161d5be5f434550ac1de800d79da7d4f68a5b5c8f265fcbd58/awscli-1.15.70-py2.py3-none-any.whl

Collecting s3transfer<0.2.0,>=0.1.12 (from awscli)

  Using cached https://files.pythonhosted.org/packages/d7/14/2a0004d487464d120c9fb85313a75cd3d71a7506955be458eebfe19a6b1d/s3transfer-0.1.13-py2.py3-none-any.whl

Collecting colorama<=0.3.9,>=0.2.5 (from awscli)

  Using cached https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl

Collecting rsa<=3.5.0,>=3.1.2 (from awscli)

  Using cached https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl

Collecting docutils>=0.10 (from awscli)

  Using cached https://files.pythonhosted.org/packages/50/09/c53398e0005b11f7ffb27b7aa720c617aba53be4fb4f4f3f06b9b5c60f28/docutils-0.14-py2-none-any.whl

Collecting PyYAML<=3.13,>=3.10 (from awscli)

  Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)

    100% |████████████████████████████████| 276kB 2.8MB/s

Collecting botocore==1.10.69 (from awscli)

  Using cached https://files.pythonhosted.org/packages/45/f3/0e5006bc6198213b853ca3975c537335a91716ffa1ed768e2b2ffe12d7ed/botocore-1.10.69-py2.py3-none-any.whl

Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.2.0,>=0.1.12->awscli)

  Using cached https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl

Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)

  Downloading https://files.pythonhosted.org/packages/d1/a1/7790cc85db38daa874f6a2e6308131b9953feb1367f2ae2d1123bb93a9f5/pyasn1-0.4.4-py2.py3-none-any.whl (72kB)

    100% |████████████████████████████████| 81kB 3.5MB/s

Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.10.69->awscli)

  Using cached https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl

Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore==1.10.69->awscli)

  Using cached https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl

Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore==1.10.69->awscli)

  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl

Building wheels for collected packages: PyYAML

  Running setup.py bdist_wheel for PyYAML ... done

  Stored in directory: /root/.cache/pip/wheels/ad/da/0c/74eb680767247273e2cf2723482cb9c924fe70af57c334513f

Successfully built PyYAML

ipaclient 4.5.4 requires jinja2, which is not installed.

rtslib-fb 2.1.63 has requirement pyudev>=0.16.1, but you'll have pyudev 0.15 which is incompatible.

ipapython 4.5.4 has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.

Installing collected packages: futures, jmespath, docutils, six, python-dateutil, botocore, s3transfer, colorama, pyasn1, rsa, PyYAML, awscli

  Found existing installation: futures 3.2.0

    Uninstalling futures-3.2.0:

      Successfully uninstalled futures-3.2.0

  Found existing installation: jmespath 0.9.3

    Uninstalling jmespath-0.9.3:

      Successfully uninstalled jmespath-0.9.3

  Found existing installation: docutils 0.14

    Uninstalling docutils-0.14:

      Successfully uninstalled docutils-0.14

  Found existing installation: six 1.9.0

    Uninstalling six-1.9.0:

      Successfully uninstalled six-1.9.0

  Found existing installation: python-dateutil 2.7.3

    Uninstalling python-dateutil-2.7.3:

      Successfully uninstalled python-dateutil-2.7.3

  Found existing installation: botocore 1.10.69

    Uninstalling botocore-1.10.69:

      Successfully uninstalled botocore-1.10.69

  Found existing installation: s3transfer 0.1.13

    Uninstalling s3transfer-0.1.13:

      Successfully uninstalled s3transfer-0.1.13

  Found existing installation: colorama 0.3.9

    Uninstalling colorama-0.3.9:

      Successfully uninstalled colorama-0.3.9

  Found existing installation: pyasn1 0.1.9

    Uninstalling pyasn1-0.1.9:

      Successfully uninstalled pyasn1-0.1.9

  Found existing installation: rsa 3.4.2

    Uninstalling rsa-3.4.2:

      Successfully uninstalled rsa-3.4.2

  Found existing installation: PyYAML 3.10

Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

You are using pip version 10.0.1, however version 18.0 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

 

$ aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

To see help text, you can run:


  aws help

  aws <command> help

  aws <command> <subcommand> help

aws: error: too few arguments

 

We can check  aws version as following:


$ aws --version

aws-cli/1.15.70 Python/2.7.5 Linux/3.10.0-693.17.1.el7.x86_64 botocore/1.10.69
 

Thats it ! We can now use AWS CLI to access the buckets in our AWS console account. :)


1 comment: