boto3 python 2.7 ImportError: No module named boto3 USER_BASE USER_SITE site packages doesn't exist

boto3 python 2.7 ImportError: No module named boto3 USER_BASE USER_SITE site packages doesn't exist

为什么 pythonpippip3 显示已安装时找不到 boto3。

我在 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 ',' '2'
[''
 '/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

我 运行 到目前为止的步骤:

[arun@ip-10.11.33-65 ~/aks] $ pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
[arun@ip-10.11.33-65 ~/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)
[arun@ip-10.11.33-65 ~/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.
[arun@ip-10.11.33-65 ~/aks] $ which python
/usr/bin/python
[arun@ip-10.11.33-65 ~/aks] $ `which python` --version
Python 2.7.10
[arun@ip-10.11.33-65 ~/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
[arun@ip-10.11.33-65 ~/aks] $

另一方面,如果我 运行 python3,它适用于 import boto3 但不适用于 import boto

这样安装:

python -m pip install --user boto3

以防万一升级到 ansible 2.4.0.0 后这对我有用:

pip install --upgrade --user boto3

重新创建了我的 $HOME/Library/Python/2.7/lib/python/site-packages

前几天我 运行 也遇到过同样的问题。我在 Mac 上安装了 python 2.7(我认为默认情况下)。然后我安装了 homebrew 并用它来获取最新版本的 python setup:
brew install python

然后,我有两个版本的python,还可以。 Brew 安装了 pip3 以及 Python 3.6.5.

然后,我能够 运行 得到 boto3:pip3 install boto3 为确保它可访问,请使用 python3 命令,而不是旧的 python。所以就我而言,我 运行 我的代码是:
python3 signURL.py

所以我是 python 的超级新手,正在做一些工作但发帖以防万一这对某人有帮助...我遇到了同样的错误,只是我在下面下载了所有内容python3 并且我正在输入 python some_script.py 导致:

File "some_script.py", line 4, in <module>
    import boto3

将其更改为 python3 some_script.py 修复了 it/found 正确的模块