it-swarm.com.ru

boto3 python 2.7 ImportError: Нет модуля с именем boto3 USER_BASE USER_SITE Пакеты сайтов не существуют

Почему python не находит boto3, когда pip или pip3 показывают, что он установлен. 

Я на Mac машина. Пробовал pip/pip3 с/без Sudo. Попытка изменить переменную PATH также с несколькими путями, но безуспешно. 

ПУТЬ: /Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/arun/.sdkman/candidates/gradle/current/bin:/Users/arun/aks/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

а также

$ python -c 'import sys; print sys.path'|tr ',' '\012'
[''
 '/Library/Python/2.7/site-packages/RBTools-0.5.7-py2.7.Egg'
 '/Library/Python/2.7/site-packages/wfawsclitools-0.1-py2.7.Egg'
 '/Library/Python/2.7/site-packages/PyYAML-3.12-py2.7-macosx-10.12-intel.Egg'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.Zip'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload'
 '/Library/Python/2.7/site-packages'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python'
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']

а также

$ python -m site
sys.path = [
    '/Users/arun/ubuntu-vagrant-box',
    '/Library/Python/2.7/site-packages/RBTools-0.5.7-py2.7.Egg',
    '/Library/Python/2.7/site-packages/wfawsclitools-0.1-py2.7.Egg',
    '/Library/Python/2.7/site-packages/PyYAML-3.12-py2.7-macosx-10.12-intel.Egg',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.Zip',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
    '/Library/Python/2.7/site-packages',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
    '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
]
USER_BASE: '/Users/arun/Library/Python/2.7' (doesn't exist)
USER_SITE: '/Users/arun/Library/Python/2.7/lib/python/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

Шаги, которые я бежал до сих пор :

[[email protected] ~/aks] $ pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
[[email protected] ~/aks] $ pip install boto3
Requirement already satisfied: boto3 in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: botocore<1.6.0,>=1.5.0 in /usr/local/lib/python2.7/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/local/lib/python2.7/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /usr/local/lib/python2.7/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /usr/local/lib/python2.7/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/python2.7/site-packages (from botocore<1.6.0,>=1.5.0->boto3)
Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /usr/local/lib/python2.7/site-packages (from s3transfer<0.2.0,>=0.1.10->boto3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python2.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.6.0,>=1.5.0->boto3)
[[email protected] ~/aks] $ pip3 install boto3
Requirement already satisfied (use --upgrade to upgrade): boto3 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): s3transfer<0.2.0,>=0.1.0 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): botocore<1.5.0,>=1.4.1 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): jmespath<1.0.0,>=0.7.1 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.10 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from botocore<1.5.0,>=1.4.1->boto3)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil<3.0.0,>=2.1 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from botocore<1.5.0,>=1.4.1->boto3)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.5.0,>=1.4.1->boto3)
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[[email protected] ~/aks] $ which python
/usr/bin/python
[[email protected] ~/aks] $ `which python` --version
Python 2.7.10
[[email protected] ~/aks] $ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named boto3
>>> ^D
[[email protected] ~/aks] $

С другой стороны, если я запускаю python3, он работает для import boto3, но не import boto.

15
Arun Sangal

Установите так:

python -m pip install --user boto3
29
wim

Я столкнулся с этой же проблемой на днях. У меня был установлен Python 2.7 на моем Mac (там по умолчанию я предполагаю). Затем я установил homebrew и использовал его, чтобы получить последнюю версию установки python:
brew install python

Затем у меня было две версии Python, и это нормально. Заварить установленный pip3 вместе с Python 3.6.5.

Итак, я смог запустить это, чтобы получить boto3: pip3 install boto3 Чтобы убедиться, что он доступен, используйте команду python3, а не старый python. Так что в моем случае я запустил свой код с:
python3 signURL.py

3
Michael

На всякий случай это сработало для меня после обновления до ansible 2.4.0.0:

pip install --upgrade --user boto3

Это воссоздал мой $HOME/Library/Python/2.7/lib/python/site-packages

1
nbari