我尝试重新安装并收到以下消息:
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
最佳答案
您应该使用virtualenv为您的项目安装依赖项。您不需要阻塞全局站点包。
例如:
sudo apt-get install virtualenv
cd ~
virtualenv your_test_venv
source your_test_venv/bin/activate
pip install troposphere
之后您就可以使用新的包了。
当您想停用 virtualenv 时,可以运行命令 deactivate
关于python 包已安装但无法导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42486550/