Python 3 ImportError: Name „Config“ kann nicht importiert werden, wenn boto3 nach der Installation mit pip3 importiert wird

Derzeit wird versucht, Python3 mit boto3 korrekt zu konfigurieren, um das AWS Dynamo Python SDK zu verwenden. Ich habe HomeBrew verwendet, um Python3 zu installieren, und dann habe ich pip und pip3 für meine Versionen von Python 2 bzw. Python 3 installiert.

Ich habe auch boto und boto3 sowohl für Python2 als auch für Python3 installiert.

workspace: python -c "import boto"
workspace: python -c "import boto3"
workspace: python3 -c "import boto"
workspace: python3 -c "import boto3"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python3.6/site-packages/boto3/session.py", line 18, in <module>
    from botocore.client import Config
ImportError: cannot import name 'Config'

Aber es ist Python 3, das mir das Problem bereitet, wie Sie oben sehen können. Hier ist mein komplettes Setup:

workspace: which python
/usr/bin/python
workspace: which python3
/usr/local/bin/python3

workspace: brew list --versions python3
python3 3.6.0_1

workspace: sudo pip install boto; sudo pip install boto3;
Requirement already satisfied: boto in /Library/Python/2.7/site-packages
Requirement already satisfied: boto3 in /Library/Python/2.7/site-packages
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Library/Python/2.7/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Library/Python/2.7/site-packages (from boto3)
Requirement already satisfied: botocore<1.6.0,>=1.5.0 in /Library/Python/2.7/site-packages (from boto3)
Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /    Library/Python/2.7/site-packages (from s3transfer<0.2.0,>=0.1.10->boto3)
Requirement already satisfied: docutils>=0.10 in /Library/Python/2.7/site-packages (from botocore<1.6.0,>=1.5.0-    >boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Library/Python/2.7/site-packages (from     botocore<1.6.0,>=1.5.0->boto3)
Requirement already satisfied: six>=1.5 in /Library/Python/2.7/site-packages (from python-dateutil<3.0.0,>=2.1->    botocore<1.6.0,>=1.5.0->boto3)    

workspace: pip3 install boto; pip3 install boto3;
Requirement already satisfied: boto in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: boto3 in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: botocore<1.6.0,>=1.5.0 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /usr/local/lib/python3.6/site-packages (from botocore<1.6.0,>=1.5.0->boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.6/site-packages (from botocore<1.6.0,>=1.5.0->boto3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.6.0,>=1.5.0->boto3)

Das Frustrierende ist, dass boto3 auf Python 2.7.10, das mit meiner macOS-Installation geliefert wurde, einwandfrei funktioniert. Aber ich möchte Python 3 verwenden und kann anscheinend nicht damit fortfahren.

Antworten (1)

Es funktioniert, wenn Sie speziell Python 3.5 installieren, nicht sicher, ob sie es bereits für 3.6 aktualisiert haben, aber kürzlich war es damit nicht kompatibel.

Das hat bei mir nicht funktioniert. Ich habe alle vorhandenen Homebrew-Versionen von Python entfernt und Python 3.5 mit diesem Tap installiert: github.com/sashkab/homebrew-python . Gleiches Problem.
Das installiert 3.5.5. Es kann sein, dass ich eine ältere 3.5-Version verwendet habe, die ich jedoch nicht mehr überprüfen kann. Die offizielle AWS-Seite sagt, dass es bis 3.4 aws.amazon.com/about-aws/whats-new/2015/06/… vollständig unterstützt wird, aber ich würde gerne denken, dass das jetzt veraltet ist. Es funktioniert definitiv mit einigen Versionen, daher kann es ein Fall von Versuch und Irrtum sein, je nachdem, welche Python-Release-Funktionalität Sie idealerweise wünschen.