使用 scikit-neuralnetwork 时导入错误

Import error while using scikit-neuralnetwork

我在 windows 8

上使用 Python 3.4 64 位的 Anaconda

在尝试使用包 scikit-neuralnetwork 时,这行代码引发了以下异常:

from sknn.mlp import Classifier, Layer

我安装了 GCC 和 g++ (4.8.1) 编译器并将它们正确添加到 PATH,但是仍然出现以下错误:

WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to               execute optimized C-implementations (for both CPU and GPU) and will default to   Python implementations. Performance will be severely degraded. To remove this   warning, set Theano flags cxx to an empty string.
Problem occurred during compilation with the command line below:
g++ -shared -g -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -IC:\Users\Mi\Anaconda3\lib\site-packages\numpy\core\include -    IC:\Users\Mi\Anaconda3\include -o C:\Users\Mi\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-3.4.3-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Mi\AppData\Local\Theano\compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-3.4.3-64\lazylinker_ext\mod.cpp -LC:\Users\Mi\Anaconda3\libs -LC:\Users\Mi\Anaconda3 -lpython34
Traceback (most recent call last):
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 65, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 82, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Mi\Desktop\temp22.py", line 10, in <module>
    from sknn.mlp import Classifier, Layer
  File "C:\Users\Mi\Anaconda3\lib\site-packages\sknn\mlp.py", line 17, in <module>
    import theano
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\__init__.py", line 55, in <module>
    from theano.compile import \
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\compile\__init__.py", line 9, in <module>
    from theano.compile.function_module import *
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 18, in <module>
    import theano.compile.mode
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\compile\mode.py", line 11, in <module>
    import theano.gof.vm
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\gof\vm.py", line 568, in <module>
    from . import lazylinker_c
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 117, in <module>
    preargs=args)
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 1989, in compile_str
    compile_stderr = decode(p_out[1])
  File "C:\Users\Mi\Anaconda3\lib\site-packages\theano\compat\__init__.py", line 35, in decode
    return x.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 10: invalid continuation byte

这个错误经常被下面的运行解决,如documentation.

中提到的
conda install mingw libpython

由于您现在已经安装了自己的 GCC,您可能需要尝试使用环境变量,尤其是 PATH 才能正常工作。