MAC OSX10.11.4 python3 import theano error

2019-03-16 08:03发布

问题:

I upgraded my Mac to a OSX 10.11.4, and sadly I found my theano cannot be imported anymore. Here is information about my machine:

➜  ~ gcc --version
Configured with: -prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The logs are list below and I hope somebody can help me out. The output is very long and I just listed part of it here. The full version can be found here.

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
00001   #include <Python.h>
00002   #include "theano_mod_helper.h"
00003   #include "structmember.h"
00004   #include <sys/time.h>
00005   
00006   #if PY_VERSION_HEX >= 0x03000000
00007   #include "numpy/npy_3kcompat.h"
00008   #define PyCObject_AsVoidPtr  NpyCapsule_AsVoidPtr
00009   #define PyCObject_GetDesc  NpyCapsule_GetDesc
00010   #define PyCObject_Check NpyCapsule_Check
00011   #endif
00012   
00013   #ifndef Py_TYPE
00014   #define Py_TYPE(obj) obj->ob_type
00015   #endif
00016   
00017   /**
00018   
00019   TODO: 
00020   - Check max supported depth of recursion
00021   - CLazyLinker should add context information to errors caught   during evaluation. Say what node we were on, add the traceback attached to the node.
00022   - Clear containers of fully-useed intermediate results if allow_gc is 1
00023   - Add timers for profiling
00024   - Add support for profiling space used.
00025   
00026   
00027     */
00028   static double pytime(const struct timeval * tv)
00029   {
00030     struct timeval t;
00031     if (!tv)
00032       {
00033         tv = &t;
00034         gettimeofday(&t, NULL);
00035       }
00036     return (double) tv->tv_sec + (double) tv->tv_usec /  1000000.0;
00037   }
00038   
00039   /**
00040     Helper routine to convert a PyList of integers to a c array of integers.
00041     */
00042   static int unpack_list_of_ssize_t(PyObject * pylist, Py_ssize_t     **dst, Py_ssize_t *len,
00043                                     const char* kwname)
00044   {
00045     Py_ssize_t buflen, *buf;
00046     if (!PyList_Check(pylist))
00047       {
00048         PyErr_Format(PyExc_TypeError, "%s must be list", kwname);
00049         return -1;
00050       }
00051     assert (NULL == *dst);
00052     *len = buflen = PyList_Size(pylist);
00053     *dst = buf = (Py_ssize_t*)calloc(buflen, sizeof(Py_ssize_t));
00054     assert(buf);
00055     for (int ii = 0; ii < buflen; ++ii)
00056       {
00057         PyObject * el_i = PyList_GetItem(pylist, ii);
00058         Py_ssize_t n_i = PyNumber_AsSsize_t(el_i, PyExc_IndexError);
00059         if (PyErr_Occurred())
00060           {
00061             free(buf);
00062             *dst = NULL;
00063             return -1;
00064           }
00065         buf[ii] = n_i;
00066       }
00067     return 0;
00068   }
00069   
00070   /**
00071   
00072     CLazyLinker
00075     */
00076   typedef struct {
00077       PyObject_HEAD
00078       /* Type-specific fields go here. */
00079       PyObject * nodes; // the python list of nodes
00080       PyObject * thunks; // python list of thunks
00081       PyObject * pre_call_clear; //list of cells to clear on   call.
00082       int allow_gc;
00083       Py_ssize_t n_applies;
00084       int n_vars;    // number of variables in the graph
00085       int * var_computed; // 1 or 0 for every variable
00086       PyObject ** var_computed_cells;
00087       PyObject ** var_value_cells;
00088       Py_ssize_t **dependencies; // list of vars dependencies for GC
00089       Py_ssize_t *n_dependencies;
00090   
00091       Py_ssize_t n_output_vars;
00092       Py_ssize_t * output_vars; // variables that *must* be evaluated by call
00093   
00094       int * is_lazy; // 1 or 0 for every thunk
00095   
00096       Py_ssize_t * var_owner; // nodes[[var_owner[var_idx]]] is var[var_idx]->owner
00097       int * var_has_owner; //  1 or 0
00098   
00099       Py_ssize_t * node_n_inputs;
00100       Py_ssize_t * node_n_outputs;
00101       Py_ssize_t ** node_inputs;
00102       Py_ssize_t ** node_outputs;
00103       Py_ssize_t * node_inputs_outputs_base; // node_inputs and node_outputs point into this
00104       Py_ssize_t * node_n_prereqs;
00105       Py_ssize_t ** node_prereqs;
00106   
00107       Py_ssize_t * update_storage; // input cells to update with the last outputs in output_vars
00108       Py_ssize_t n_updates;
00109   
00110       void ** thunk_cptr_fn;
00111       void ** thunk_cptr_data;
00112       PyObject * call_times;
00113       PyObject * call_counts;
00114       int do_timing;
00115       int need_update_inputs;
00116       int position_of_error; // -1 for no error, otw the index into `thunks` that failed.
00117   } CLazyLinker;
...............
=   ==============================
   Problem occurred during compilation with the command line below:
   /usr/bin/clang++ -dynamiclib -g -march=haswell -target-feature -sse4a -target-feature -avx512bw -target-feature +cx16 -target-feature -tbm -target-feature +xsave -target-feature -fma4 -target-feature -avx512vl -target-feature -prfchw -target-feature +bmi2 -target-feature -adx -target-feature -xsavec -target-feature +fsgsbase -target-feature +avx -target-feature -avx512cd -target-feature -avx512pf -target-feature -rtm -target-feature +popcnt -target-feature +fma -target-feature +bmi -target-feature +aes -target-feature +rdrnd -target-feature -xsaves -target-feature +sse4.1 -target-feature +sse4.2 -target-feature +avx2 -target-feature -avx512er -target-feature +sse -target-feature +lzcnt -target-feature +pclmul -target-feature -avx512f -target-feature +f16c -target-feature +ssse3 -target-feature +mmx -target-feature +cmov -target-feature -xop -target-feature -rdseed -target-feature +movbe -target-feature -hle -target-feature +xsaveopt -target-feature -sha -target-feature +sse2 -target-feature +sse3 -target-feature -avx512dq -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof -fvisibility=hidden -o /Users/liuwei/.theano/compiledir_Darwin-15.4.0-x86_64-i386-64bit-i386-3.5.1-64/lazylinker_ext/lazylinker_ext.so /Users/liuwei/.theano/compiledir_Darwin-15.4.0-x86_64-i386-64bit-i386-3.5.1-64/lazylinker_ext/mod.cpp -L/Library/Frameworks/Python.framework/Versions/3.5/lib
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-sse4a'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-tbm'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-fma4'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-prfchw'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-rtm'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-rdseed'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-hle'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-sha'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: unknown argument: '-target-feature'
   clang: error: no such file or directory: '+cx16'
   clang: error: no such file or directory: '+xsave'
   clang: error: no such file or directory: '+bmi2'
   clang: error: language not recognized: 'savec'
   clang: error: no such file or directory: '+fsgsbase'
   clang: error: no such file or directory: '+avx'
   clang: error: no such file or directory: '+popcnt'
   clang: error: no such file or directory: '+fma'
   clang: error: no such file or directory: '+bmi'
   clang: error: no such file or directory: '+aes'
   clang: error: no such file or directory: '+rdrnd'
   clang: error: language not recognized: 'saves'
   clang: error: no such file or directory: '+sse4.1'
   clang: error: no such file or directory: '+sse4.2'
   clang: error: no such file or directory: '+avx2'
   clang: error: no such file or directory: '+sse'
   clang: error: no such file or directory: '+lzcnt'
   clang: error: no such file or directory: '+pclmul'
   clang: error: no such file or directory: '+f16c'
   clang: error: no such file or directory: '+ssse3'
   clang: error: no such file or directory: '+mmx'
   clang: error: no such file or directory: '+cmov'
   clang: error: language not recognized: 'op'
   clang: error: no such file or directory: '+movbe'
   clang: error: no such file or directory: '+xsaveopt'
   clang: error: no such file or directory: '+sse2'
   clang: error: no such file or directory: '+sse3'

   Traceback (most recent call last):
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof/lazylinker_c.py", line 74, in <module>
       raise ImportError()
   ImportError

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof/lazylinker_c.py", line 91, in <module>
       raise ImportError()
   ImportError

   During handling of the above exception, another exception occurred:

   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/__init__.py", line 63, in <module>
       from theano.compile import (
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
       from theano.compile.function_module import *
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
       import theano.compile.mode
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/compile/mode.py", line 12, in <module>
       import theano.gof.vm
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof/vm.py", line 638, in <module>
       from . import lazylinker_c
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof/lazylinker_c.py", line 126, in <module>
       preargs=args)
     File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/theano/gof/cmodule.py", line 2196, in compile_str
       (status, compile_stderr.replace('\n', '. ')))
   Exception: Compilation failed (return status=1): 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-sse4a'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-tbm'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-fma4'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-prfchw'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-rtm'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'.
    clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-rdseed'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-hle'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-sha'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: unknown argument: '-target-feature'. 
   clang: error: no such file or directory: '+cx16'. 
   clang: error: no such file or directory: '+xsave'. 
   clang: error: no such file or directory: '+bmi2'. 
   clang: error: language not recognized: 'savec'. 
   clang: error: no such file or directory: '+fsgsbase'. 
   clang: error: no such file or directory: '+avx'. 
   clang: error: no such file or directory: '+popcnt'. 
   clang: error: no such file or directory: '+fma'. 
   clang: error: no such file or directory: '+bmi'. 
   clang: error: no such file or directory: '+aes'. 
   clang: error: no such file or directory: '+rdrnd'. 
   clang: error: language not recognized: 'saves'. 
   clang: error: no such file or directory: '+sse4.1'. 
   clang: error: no such file or directory: '+sse4.2'. 
   clang: error: no such file or directory: '+avx2'. 
   clang: error: no such file or directory: '+sse'. 
   clang: error: no such file or directory: '+lzcnt'. 
   clang: error: no such file or directory: '+pclmul'. 
   clang: error: no such file or directory: '+f16c'. 
   clang: error: no such file or directory: '+ssse3'. 
   clang: error: no such file or directory: '+mmx'. 
   clang: error: no such file or directory: '+cmov'. 
   clang: error: language not recognized: 'op'. 
   clang: error: no such file or directory: '+movbe'. 
   clang: error: no such file or directory: '+xsaveopt'. 
   clang: error: no such file or directory: '+sse2'. 
   clang: error: no such file or directory: '+sse3'.

回答1:

The problem comes from an interface change in Xcode 7.3. It is fixed in the current master of Theano and there will be release 0.8.1 next Tuesday (2016/03/29) that will be 0.8.0 + the fix.

In the meantime you can either run the master: http://deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions or install version 7.2 of the command line tools and select those with xcode-select to make Theano work.



回答2:

A new Numpy release (1.11.0) came out yesterday, 3/27/16. Installed it and finally everything on my MacBook OS-X Canopy Python started working correctly. Installed scikit-neuralnetwork, which installs Theano, Numpy, and others. Whew...