Hi, I am a beginner with python and installed the Brian Library.
I compiled the test code but it had a many Fails.
And if I compiled the Example code, there was Warning that Cannnot use Cython, a test compilation failed.
How can i fix this problem
WARNING Cannot use Cython, a test compilation failed: command ‘/Users/imhyeonseong/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-clang++’ failed with exit code 1 (LinkError)
Certain compiler configurations (e.g. clang in a conda environment on OS X) are known to be problematic. Note that you can switch the compiler by setting the ‘CC’ and ‘CXX’ environment variables. For example, you may want to try ‘CC=gcc’ and ‘CXX=g++’. [brian2.codegen.runtime.cython_rt.cython_rt.failed_compile_test]
INFO Cannot use compiled code, falling back to the numpy code generation target. Note that this will likely be slower than using compiled code. Set the code generation to numpy manually to avoid this message:
prefs.codegen.target = “numpy” [brian2.devices.device.codegen_fallback]
packages in environment at /Users/imhyeonseong/opt/anaconda3:
Hi @ImHS . Not having a working Cython isn’t a big problem, it will only make your simulations a bit slower. As the log message says, you can disable it manually to avoid the error:
prefs.codegen.target = “numpy”
While this will lead to slightly slower simulations, it has the advantage that it does not need to compile code first, i.e. the time until the actual simulation starts is shorter. Especially for simpler simulations, or during development where you change/re-run simulations very often, this can actually be faster in total.
For fixing the issue with Cython, did you try what the info message suggested? You seem to be in the exact situation it mentions (conda on OS X):
Hi @ImHS. Glad it worked out! There are several ways to set environment variables permanently. You can set them globally it in your “bash profile” file(see e.g. How to Set Environment Variables in MacOS | phoenixNAP KB), but I wouldn’t necessarily recommend it since it could break other programs and can potentially lead to issues that are hard to debug.
Another solution would be to set these variables only for the conda environment, as described by @adam here: How to override CXX enviroment variables set by · GitHub Note that in your case, I don’t think you are using a dedicated environment, so you should apply the instructions to the base environment. The instructions also set CLANG and CLANGXX, but this turned out not to be necessary, setting CC and CXX is enough.
Finally, you can also set environment variables directly in a Python script by using something like this:
os.environ['CC'] = 'gcc'
os.environ['CXX'] = 'g++'