尝试使用虚拟环境在MacOSX中运行Keras
版本
疑难解答
日志
(venv) me$sudo pip install --upgrade keras
Collecting keras
Requirement already up-to-date: six in /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg (from keras)
Requirement already up-to-date: pyyaml in /Library/Python/2.7/site-packages (from keras)
Requirement already up-to-date: theano in /Library/Python/2.7/site-packages (from keras)
Requirement already up-to-date: numpy>=1.9.1 in /Library/Python/2.7/site-packages (from theano->keras)
Requirement already up-to-date: scipy>=0.14 in /Library/Python/2.7/site-packages (from theano->keras)
Installing collected packages: keras
Successfully installed keras-2.0.5
(venv) me$ python -c "import keras; print(keras.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named keras
答案 0 :(得分:2)
这里的根本问题是当你使用sudo
时,pip
指向全局的系统级python而不是virtual-env python。这就是为什么在没有sudo
的情况下安装时,它可以无缝地为您工作。你可以通过在virtualenv中运行sudo pip install --upgrade keras
然后在virtualenv之外运行python -c "import keras; print(keras.__version__)"
来检查这一点。