Import theano gives the AttributeError: module 'theano' has no attribute 'gof'

前端 未结 3 1455
面向向阳花
面向向阳花 2021-01-02 05:37

I have python 3. I installed \"Theano\" bleeding edge and \"Keras\" using

pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
相关标签:
3条回答
  • 2021-01-02 06:05

    The problem seems to be with your g++ compiler. Try uninstalling it and running your script again. It'll spit a warning implying a degradation in performance, but it'll work nonetheless.

    'Python 3.6.3 |Anaconda custom (32-bit)| 
    (default, Oct 15 2017, 07:29:16)       
    [MSC v.1900 32 bit (Intel)]
    Type "copyright", "credits" or "license" for more information.
    
    IPython 6.1.0 -- An enhanced Interactive Python.
    
    import theano
    WARNING (theano.tensor.blas): Using NumPy C-API based implementation 
    for BLAS functions.
    '
    
    0 讨论(0)
  • 2021-01-02 06:06

    I used conda to install theano and still got the same error. After much trial and error and StackOverflow searches, what worked for me was to first run:

    conda install m2w64-toolchain
    

    followed by:

    conda install theano
    

    Alternatively you can chain the modules together when you create an environment, for example:

    conda create -n myenv python=3.5 m2w64-toolchain theano
    

    Also important to follow @gtnbz2nyt's advice and restart your Python instance.

    0 讨论(0)
  • 2021-01-02 06:09

    The problem arises from a broken installation of theano and has nothing to do with keras itself.

    This error seems to be due to conflicts in the installed version of theano, as also suggested in this answer to a related question.

    An easy way that should solve the problem without having to fiddle with the installed version and all that is to use conda as package manager and let it do the dirty work. If you choose to do this be aware that you should manage all of your python modules with it (even though with the latest versions you can install packages with the pip shipped with anaconda itself).

    See the official documentation for how to install Anaconda. Once anaconda is set up you can install theano using simply conda install theano.

    With conda is also often convenient to install the packages needed for some particular application, like Keras in your case, in an environment isolated from the rest of your python installation, for easier maintenance. Read the relevant docs to see how this would work.

    0 讨论(0)
提交回复
热议问题