我已经安装了Theano:
(python2) bash-3.2$ sudo pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
我在Python 2.7中使用conda。括号中的python2
是我的conda环境。我正在尝试从iGAN运行代码:https://github.com/junyanz/iGAN。我在OS X 10.11.6上。
我得到的错误是ImportError: cannot import name inplace_increment
。我已经尝试手动删除Theano缓存(如https://github.com/Theano/Theano/issues/5564中所述)并且仍然出现相同的错误。 (我不能使用theano-cache purge
因为它需要安装与OpenCV所需版本冲突的scipy版本。)我也尝试通过pip卸载并重新安装Theano但仍然得到相同的错误。有什么建议吗?
以下是上下文:
(python2) bash-3.2$ python iGAN_main.py
//anaconda/envs/python2/lib/python2.7/site-packages/numpy/lib/utils.py:254: FutureWarning: Numpy has detected that you (may be) writing to an array returned
by numpy.diagonal or by selecting multiple fields in a record
array. This code will likely break in the next numpy release --
see numpy.diagonal or arrays.indexing reference docs for details.
The quick fix is to make an explicit copy (e.g., do
arr.diagonal().copy() or arr[['f0','f1']].copy()).
ai = a.__array_interface__
Traceback (most recent call last):
File "iGAN_main.py", line 9, in <module>
import constrained_opt
File "/Users/katherineye/Desktop/Code/iGAN/constrained_opt.py", line 3, in <module>
from lib.rng import np_rng
File "/Users/katherineye/Desktop/Code/iGAN/lib/rng.py", line 2, in <module>
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/__init__.py", line 102, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/__init__.py", line 9, in <module>
from theano.tensor.subtensor import *
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/subtensor.py", line 27, in <module>
from cutils_ext.cutils_ext import inplace_increment
ImportError: cannot import name inplace_increment
答案 0 :(得分:5)
我遇到了同样的问题。
手动删除缓存。
rm -rf ~/.theano
如果这样做无助于尝试从源代码安装。
python setup.py install