boto3无法导入名称副本

时间:2018-04-10 10:44:21

标签: python boto3 aws-cli

几周前我安装了boto3,直到现在一切正常 试图重新安装pip,重新安装boto3,重新安装aws cli,更新机器(yum update)但没有任何帮助

 File "./get_reports.py", line 4, in <module>
    import boto3
  File "/usr/lib/python2.7/site-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/lib/python2.7/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/lib/python2.7/site-packages/botocore/session.py", line 25, in <module>
    import botocore.configloader
  File "/usr/lib/python2.7/site-packages/botocore/configloader.py", line 19, in <module>
    from botocore.compat import six
  File "/usr/lib/python2.7/site-packages/botocore/compat.py", line 172, in <module>
    import xml.etree.cElementTree
  File "/usr/lib64/python2.7/xml/etree/cElementTree.py", line 3, in <module>
    from _elementtree import *
  File "<string>", line 1, in <module>
ImportError: cannot import name copy




aws --version
aws-cli/1.15.3 Python/2.7.5 Linux/3.10.0-693.17.1.el7.x86_64 botocore/1.10.3

使用botocore时出现相同的错误

代码:

#!/usr/bin/env python


import boto3
import json
import csv

client = boto3.client('iam')

response = client.get_account_authorization_details(


)

2 个答案:

答案 0 :(得分:0)

您的boto3版本可能与botocore

不同

尝试运行

pip freeze| grep boto

如果版本不同,请运行

pip install --upgrade botocore
pip install --upgrade boto3

答案 1 :(得分:0)

是否有可能在当前目录中有一个copy.py文件?如果是这种情况,请尝试重命名