简体   繁体   中英

Theano step gives File in wrong format error

I am trying to replicate the example Getting Started PyMC3 .

on Windows 2012 R2.

The step from pymc3 import Model, Normal, HalfNormal
gives

D:\Anaconda3\libs/python35.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status

    ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
     64         if version != getattr(lazylinker_ext, '_version', None):
---> 65             raise ImportError()
     66 except ImportError:

ImportError: 

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
     81             if version != getattr(lazylinker_ext, '_version', None):
---> 82                 raise ImportError()
     83         except ImportError:

ImportError: 

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-4-582c90a634a6> in <module>()
----> 1 from pymc3 import Model, Normal, HalfNormal

D:\Anaconda3\lib\site-packages\pymc3\__init__.py in <module>()
      1 __version__ = "3.0"
      2 
----> 3 from .core import *
      4 from .distributions import *
      5 from .math import *

D:\Anaconda3\lib\site-packages\pymc3\core.py in <module>()
      1 from .vartypes import *
----> 2 from .model import *
      3 from .theanof import *
      4 from .blocking import *
      5 import numpy as np

D:\Anaconda3\lib\site-packages\pymc3\model.py in <module>()
      1 from .vartypes import *
      2 
----> 3 from theano import theano, tensor as t, function
      4 from theano.tensor.var import TensorVariable
      5 

D:\Anaconda3\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils
     54 
---> 55 from theano.compile import \
     56     SymbolicInput, In, \
     57     SymbolicOutput, Out, \

D:\Anaconda3\lib\site-packages\theano\compile\__init__.py in <module>()
      7         SpecifyShape, specify_shape, register_specify_shape_c_code)
      8 
----> 9 from theano.compile.function_module import *
     10 
     11 from theano.compile.mode import *

D:\Anaconda3\lib\site-packages\theano\compile\function_module.py in <module>()
     16 from theano import gof
     17 from theano.compat.python2x import partial
---> 18 import theano.compile.mode
     19 from theano.compile.io import (
     20     In, SymbolicInput, SymbolicInputKit, SymbolicOutput)

D:\Anaconda3\lib\site-packages\theano\compile\mode.py in <module>()
      9 import  theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano.configparser import config, AddConfigVar, StrParam
     13 from theano.compile.ops import register_view_op_c_code, _output_guard

D:\Anaconda3\lib\site-packages\theano\gof\vm.py in <module>()
    566 
    567 try:
--> 568     from . import lazylinker_c
    569 
    570     class CVM(lazylinker_c.CLazyLinker, VM):

D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
    115             args = cmodule.GCC_compiler.compile_args()
    116             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 117                                              preargs=args)
    118             # Save version into the __init__.py file.
    119             init_py = os.path.join(loc, '__init__.py')

D:\Anaconda3\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module)
   2008             # difficult to read.
   2009             raise Exception('Compilation failed (return status=%s): %s' %
-> 2010                             (status, compile_stderr.replace('\n', '. ')))
   2011         elif config.cmodule.compilation_warning and compile_stderr:
   2012             # Print errors just below the command line.

I have for gcc

C:\>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lt
o-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64-mingw32 --e
nable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable
-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC -
-disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-d
ebug --enable-threads=posix --enable-version-specific-runtime-libs --enable-full
y-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-l
d --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm -
-with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://td
m-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm64-1)

what am i missing?

thanks

Whatever the issue was creating a python 3.4 environment together with

conda install mingw libpython

solved it.

什么解决了我的问题是安装Python 2.7版本的anaconda

I got the same error using ipython. Using just python I imported theano without problem. Subsequent uses with ipython worked fine after the first compilation with just python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM