2017-02-27 78 views
0

我试图重新安装,并得到了以下消息:Python包,但无法导入

Requirement already satisfied: troposphere==1.8.2 in /usr/local/lib/python2.7/site-packages (from -r requirements.txt (line 13) 

我检查我的Python版本,我可以认为这是相同的:

animjain$ python -V 
Python 2.7.10 

当我尝试导入模块时,出现以下错误:

animjain$ python 
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from troposphere import Join, Ref, FindInMap 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named troposphere 
+1

你有蟒蛇的多个版本的机器上? – WhatsThePoint

+0

是的我有多个版本的Python运行。我会试着看看下面的东西是否可行......如果你想添加什么意思,请:) :) –

+0

如果你有多个版本的python运行,那么你最有可能将模块安装到错误的版本 – WhatsThePoint

回答

1

如果您的计算机上有多个Python版本,则ins身高与同Python的命令,所以不是:

animjain$ pip install troposphere==1.8.2 

运行:

animjain$ python -mpip install troposphere==1.8.2 
1

您应该使用virtualenv安装依赖于你的项目。您不需要堵塞全球站点包。

例如:

sudo apt-get install virtualenv 
cd ~ 
virtualenv your_test_venv 
source your_test_venv/bin/activate 
pip install troposphere 

之后,你可以使用你的新包。

当你要停用的virtualenv可以运行命令deactivate