import theano时报错ImportError: No module named cPickle

>>> import theano
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.7/site-packages/theano/__init__.py", line 52, in 
    from theano.gof import (
  File "/Library/Python/2.7/site-packages/theano/gof/__init__.py", line 38, in 
    from theano.gof.cc import \
  File "/Library/Python/2.7/site-packages/theano/gof/cc.py", line 25, in 
    from theano.gof import link
  File "/Library/Python/2.7/site-packages/theano/gof/link.py", line 18, in 
    from theano.gof.type import Type
  File "/Library/Python/2.7/site-packages/theano/gof/type.py", line 17, in 
    from theano.gof.op import CLinkerObject
  File "/Library/Python/2.7/site-packages/theano/gof/op.py", line 25, in 
    from theano.gof.cmodule import GCC_compiler
  File "/Library/Python/2.7/site-packages/theano/gof/cmodule.py", line 8, in 
    import six.moves.cPickle as pickle
ImportError: No module named cPickle

原因是:

theano要求six的版本在1.9.0以上,以前装了低于该版本的six包。


解决方法:

1.在命令行中输入:python,进入python的命令行模式;

2.依次输入以下命令

import six
print six.__version__
print six.__file__

3.去import的目录下删除跟six有关的文件:six.py  six.pyc

4.在命令行中输入:sudo pip install six

done

如果还不行就在4之前再执行一次sudo pip uninstall six

你可能感兴趣的:(import theano时报错ImportError: No module named cPickle)