2017-03-01 119 views
4

为什么pythonpippip3显示已安装时未找到boto3。boto3 python 2.7 ImportError:没有名为boto3的模块USER_BASE USER_SITE站点包不存在

我在Mac机器。尝试点/ pip3有/没有sudo。尝试改变PATH变量以及几条路径,但没有运气。

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

+0

什么是'蟒-c输出'进口系统;打印sys.path''?它包含'/ usr/local/lib/python2.7/site-packages'吗? – Leon

+0

@Leon不,它没有,更新我的问题与你的裁判输出。 –

+0

试试这个:'PYTHONPATH =/usr/local/lib/python2.7/site-packages python -c'import boto3;打印目录(boto3)''。 – Leon

回答

9

安装这样的:

python -m pip install --user boto3 
+0

工作,我想知道为什么你有89.9k :)另外,对于python3提示符,'import boto'不工作,运行'python3 -m pip install --user boto'也修复了这个问题。所以,现在我的'python'和'python3'都在提示符或者在.py python程序中运行'import boto'和'import boto3',其中'import'语句存在于boto/boto3中。 –

+0

与'import credstash'相同的问题,通过运行'python -m pip install --user credstash'修复。 –

+0

帮助我太多了。谢谢! –

0

万一这个升级到ansible 2.4.0.0后为我工作:

pip install --upgrade --user boto3 

那我重新$HOME/Library/Python/2.7/lib/python/site-packages

相关问题