Theano import error: No module named cPickle

匿名 (未验证) 提交于 2019-12-03 02:51:02

问题:

>>> 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:  

回答1:

I had the same problem and upgrading six solved issue:

sudo easy_install --upgrade six 


回答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 :)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!