问题
I am having some problems 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 get
-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 much appreciated.
EDIT
Somehow the problem was I had to run the aws commands with sudo.
回答1:
I came across similar problem when I did xml parsing in Python (2.7). Finally, it was figured out that it was caused by the inaccurately defined LD_LIBRARY_PATH
environment variable. Here was my situation: the xml parsing library: libexpat.so was confused with the MATLAB version (libexpat.so.1.5.0) between the system version (libexpat.so.1.6.0), the ImportError
arose when loaded the MATLAB version libexpat.so, after I precisely defined the LD_LIBRARY_PATH
, that is excluding MATLAB library path, everything went smoothly.
来源:https://stackoverflow.com/questions/25934479/pyexpat-import-error-when-running-aws-cli