g ++不可用,如果使用conda:`conda install m2w64-toolchain`

时间:2018-02-17 05:59:11

标签: python tensorflow g++ theano conda

在关注这些教程Neural net的过程中,在运行test.py文件时,我收到了这些异常和警告。我已经尝试过以前的建议,但没有任何效果。

WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\ProgramData\Anaconda3\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
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.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

任何正确的解决方案都将受到赞赏。

尝试conda install m2w64-toolchain后。另一个错误是,

*You can find the C code in this temporary file: C:\Users\CERTAI~1\AppData\Local\Temp\theano_compilation_error_7bgw9_s9
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\shubhamprojectwork\all Work 2018\kaggle\DeepLearningPython35-master\DeepLearningPython35-master\test.py", line 156, in <module>
    import network3
  File "C:\shubhamprojectwork\all Work 2018\kaggle\DeepLearningPython35-master\DeepLearningPython35-master\network3.py", line 37, in <module>
    import theano
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\__init__.py", line 110, in <module>
    from theano.compile import (
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
    from theano.compile.mode import *
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\compile\mode.py", line 11, in <module>
    import theano.gof.vm
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\vm.py", line 673, in <module>
    from . import lazylinker_c
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 127, in <module>
    preargs=args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 2359, in compile_str
    (status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `_import_array':
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1470: undefined reference to `__imp_PyExc_ImportError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1476: undefined reference to `__imp_PyExc_AttributeError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1481: undefined reference to `__imp_PyCapsule_Type'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1482: undefined reference to `__imp_PyExc_RuntimeError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1497: undefined reference to `__imp_PyExc_RuntimeError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1505: undefined reference to `__imp_PyExc_RuntimeError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1511: undefined reference to `__imp_PyExc_RuntimeError'
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1521: undefined reference to `__imp_PyExc_RuntimeError'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o:C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1533: more undefined references to `__imp_PyExc_RuntimeError' follow
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `NpyCapsule_Check':
. C:/ProgramData/Anaconda3/lib/site-packages/numpy/core/include/numpy/npy_3kcompat.h:456: undefined reference to `__imp_PyCapsule_Type'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `unpack_list_of_ssize_t':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:48: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:58: undefined reference to `__imp_PyExc_IndexError'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `CLazyLinker_init':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:352: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:370: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:385: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:389: undefined reference to `__imp_PyExc_IndexError'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o:C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:393: more undefined references to `__imp_PyExc_IndexError' follow
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `CLazyLinker_init':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:405: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:420: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:426: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:440: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:444: undefined reference to `__imp__Py_NoneStruct'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `c_call':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:545: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:545: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:545: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:546: undefined reference to `__imp__Py_NoneStruct'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o:C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:546: more undefined references to `__imp__Py_NoneStruct' follow
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `lazy_rec_eval':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:618: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:641: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:649: undefined reference to `__imp_PyExc_ValueError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:657: undefined reference to `__imp_PyExc_IndexError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:708: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:715: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:721: undefined reference to `__imp_PyExc_TypeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:771: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:771: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:772: undefined reference to `__imp__Py_NoneStruct'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `CLazyLinker_call':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:814: undefined reference to `__imp_PyExc_RuntimeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:826: undefined reference to `__imp_PyExc_RuntimeError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:839: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:839: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:840: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:849: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:849: undefined reference to `__imp__Py_NoneStruct'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o:C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:850: more undefined references to `__imp__Py_NoneStruct' follow
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `CLazyLinker_call':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:894: undefined reference to `__imp_PyExc_AssertionError'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:937: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:937: undefined reference to `__imp__Py_NoneStruct'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:938: undefined reference to `__imp__Py_NoneStruct'
. C:\Users\CERTAI~1\AppData\Local\Temp\ccFdFXU1.o: In function `CLazyLinker_set_allow_gc':
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:973: undefined reference to `__imp_PyBool_Type'
. C:/Users/Certainty1/AppData/Local/Theano/compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.1-64/lazylinker_ext/mod.cpp:976: undefined reference to `__imp__Py_TrueStruct'
. collect2.exe: error: ld returned 1 exit status
.* 

4 个答案:

答案 0 :(得分:4)

根据我个人的经验,连续错误是由于不存在(或根本没有找到)python * .dll for windows引起的。您可以通过'conda install libpython'

解决此问题

答案 1 :(得分:2)

对于那些做了on this page却做了一切但仍然遇到以下消息的人(这意味着您将大大降低性能):

WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\user\miniconda3\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn("DeprecationWarning: there is no c++ compiler."
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.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

我可以找到此消息的来源:它位于python环境安装<path_to_your_python_env>/Lib/site-packages/theano/misc/windows.py的路径中。在方法subprocess_Popen中,您将找到字符串

params['shell'] = True

您需要删除或注释掉。检查g ++和c ++编译器是否存在是通过调用此方法来进行的。并且使用shell=True参数会在Windows计算机上导致未找到的错误(已被静音,因此您永远不会知道[老实说,我不知道是谁决定这样做的])。该错误很可能是因为传递给subprocess.Popen的系统调用命令已损坏并带有以下符号:it is recommended在使用args时使用字符串shell=True参数,而Theano的作者不遵守(他们的通过列表)。

如果shell为True,建议将args作为字符串而不是序列传递。

一旦我注释掉了这个字符串并尝试导入Theano / PyMC3,消息就消失了,我可以享受那些令人惊叹的工具的最高性能。

答案 2 :(得分:1)

我有同样的错误。在我的电脑上我有python 3.6。我这样做了:
1.我卸载并重新安装了conda 2.我使用带有python 3.5的conda创建了一个环境 3.在环境中安装m2w64-toolchain

它有效!

答案 3 :(得分:0)

我昨天遇到了同样的问题。

我已经下载并安装了g ++,因为theano需要这个才能工作

请点击此链接了解如何下载和安装

http://www.instructables.com/id/How-to-Install-MinGW-GCCG-Compiler-in-Windows-XP78/

将路径添加到我的环境后,我卸载并重新安装了anaconda。

我为python 3.5创建了一个新环境 激活它然后我按照这里的说明安装theano

http://deeplearning.net/software/theano/install_windows.html

他们的步骤将我的python降级为2.7

然后我做了以下

1:pip安装未来 2:pip安装枕头 3:conda install nb_conda_kernels 4:pip install future --upgrade 5:添加了环境变量 - MKL_THREADING_LAYER = GNU 6:重启我的终端,一切正常。

我不需要为后续环境完成这些初始步骤 激活python 3.5环境后,执行

conda安装theano设置我需要的一切

希望有所帮助