Pyexpat import error when running the aws cli… here is a solution to the problem.
Pyexpat import error when running the aws cli
I’m having some issues running the AWS CLI on Ubuntu 14.04
I keep getting the following error
Traceback (most recent call last):
File "/usr/local/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 16, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 27, in <module>
import botocore.credentials
File "/usr/local/lib/python2.7/dist-packages/botocore/credentials.py", line 23, in <module>
from botocore.compat import total_seconds
File "/usr/local/lib/python2.7/dist-packages/botocore/compat.py", line 118, in <module>
import xml.etree.cElementTree
File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
from _elementtree import *
ImportError: PyCapsule_Import could not import module "pyexpat"
When I do
ls -l /usr/lib/python2.7/*/pyexpat*
I see
-rw-r--r-- 1 root root 69200 Mar 23 01:57 /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
Any help is greatly appreciated.
Edit
Somehow, the problem is that I have to run aws commands using sudo.
Solution
I’m having a similar issue parsing xml in Python (2.7). It was eventually identified as the result of LD_LIBRARY_PATH
inaccurate definition of environmental variables. Here’s my case: XML parsing library: The MATLAB version (libexpat.so.1.5.0) between libexpat.so and the system version () confuses libexpat.so.1.6.0), and an ImportError appears when loading MATLAB version libexpat.so
, after I defined the LD_LIBRARY_PATH
precisely, i.e. excluding the MATLAB library path, and all went well.