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

I'm pretty sure there is no problem with cPickle. Can it be the problem of other dependencies? It's true that I upgraded all the packages this morning, so that a conflict of version may occur. Nonetheless, the problem still exists after I switched to the bleeding-edge version of theano. Would someone help me figure it out?

PS: My developing device is Macbook Pro 13(early 2015); my system version is OS X 10.10.5; python version is 2.7.10

=========================== Second Edit ===================================

It seems I do have latest version of six installed on my Mac.

YiqundeMacBook-Pro:~ Leo$ pip show six
---
Metadata-Version: 2.0
Name: six
Version: 1.9.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /Library/Python/2.7/site-packages
Requires: 
Yiqun Liu
  • 503
  • 2
  • 5
  • 14
  • `six` is a compatibility package between Python 2 and Python 3 code. For some reason it doesn't determine you have `cPickle` module available even though Python 2 always has it. I suggest you open the `six.moves` source and try to figure what's going on there. – Mikko Ohtamaa Sep 20 '15 at 13:10
  • There is no `six.moves` source and the way `six` "determines" if `cPickle` is available is essentially hardcoded into it based on whether it's running under Python 2 or 3. Make sure you have the latest version of `six` (1.9.0) installed. If so, report the problem as a bug via [https://bitbucket.org/gutworth/six](https://bitbucket.org/gutworth/six). – martineau Sep 20 '15 at 14:22
  • @martineau I'm sure I have the latest version of 'six'.(see my latest update of the question) – Yiqun Liu Sep 20 '15 at 14:46
  • Then it looks like a bug in `six` to me because the `import six.moves.cPickle as pickle` should work based on the [documentation](http://pythonhosted.org/six/#module-six.moves) and source code for it I've looked at — so I think you should report it as such to let Benjamin (the author) know. You may be able to work around the problem by changing the `cmodule.py` source yourself (to just `import cPickle as pickle` since you're using Python 2). – martineau Sep 20 '15 at 14:58
  • I have the same issue with CentOS 6.x – Shockley Jan 05 '16 at 20:59

2 Answers2

7

I had the same problem and upgrading six solved issue:

sudo easy_install --upgrade six
Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
dipendra009
  • 299
  • 2
  • 7
2

Try to avoid using sudo at all costs. Open a python session and run

import six
print six.__version__
print six.__file__

The version will likely not be most recent (1.10.0), so go manually delete the six.py and six.pyc files at the imported path, and then run pip install six. Python should now be importing the latest version of six, compatible with Theano :)

BoltzmannBrain
  • 5,082
  • 11
  • 46
  • 79