3

我正在尝试复制示例 Getting Started PyMC3

在 Windows 2012 R2 上。

该步骤 from pymc3 import Model, Normal, HalfNormal
给出

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.

我有 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)

我错过了什么?

谢谢

4

3 回答 3

6

无论问题是与创建 python 3.4 环境

conda install mingw libpython

解决了。

于 2015-12-01T19:25:45.283 回答
0

我使用 ipython 遇到了同样的错误。只使用 python 我导入了 theano 没有问题。在第一次仅使用 python 编译之后,随后使用 ipython 运行良好。

于 2017-01-08T23:28:14.850 回答
0

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

于 2016-05-04T11:20:30.873 回答