Pyexpat import error when running aws cli

我只是一个虾纸丫 提交于 2020-01-04 03:51:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!