Pyexpat import error when running aws cli

I'm having trouble getting aws cli to run 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/", line 16, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/", line 27, in <module>
import botocore.credentials
File "/usr/local/lib/python2.7/dist-packages/botocore/", line 23, in    <module>
from botocore.compat import total_seconds
File "/usr/local/lib/python2.7/dist-packages/botocore/", line 118, in <module>
import xml.etree.cElementTree
File "/usr/lib/python2.7/xml/etree/", 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 get

 -rw-r--r-- 1 root root 69200 Mar 23 01:57 /usr/lib/python2.7/lib-dynload/


Any help is greatly appreciated.


Somehow the problem was that I had to run aws commands with sudo.


source to share

1 answer

I had to face a similar problem when I was parsing xml in Python (2.7). Finally, it turned out that it was caused by an inaccurately defined environment variable LD_LIBRARY_PATH

. Here is my situation: xml syntax parsing library: was confused with the MATLAB version ( between the system version (, ImportError

occurred when loading MATLAB version, after I figured out exactly LD_LIBRARY_PATH

which excludes the MATLAB library path, everything went smoothly.



All Articles