How to solve "can not import name 'Brain' from 'Surfer'

Hello, I solved the problem,

solution:

conda create --name=mne  python=3.7

instead of

conda create --name=mne --channel=conda-forge mne

then installed successfully:D

@CliffordTHU this does not solve the problem unfortunatelly. This way you install an environment called mne that contains only python, but not the mne package.

Could you say what exactly happens when you try to install the 3d mne environment? Below that comment you pasted an example of trying to update conda package of the base environment and it wasn’t updated because in your case it is up to date. But your earlier examples of installing mne looked as if they were either not copied in full or the installation process was terminated.

Also - check if you antivirus does not complain during the installation. I just had an installation stuck for about 30 minutes, because I didn’t notice that my antivirus “blocked a threat”, which was one of the installation components (a false alarm), after adding it to exceptions list the installation progressed.

Hello, sorry for didn’t reply 2 days, I thaught I accomplished the problem, however,

when debug,


it comes to:

somehow it can’t import surfer

yes, I used this command to create a environment called mne, then download all packages it needs, I thaught this works

when I installed 3d part by
conda create --name=mne --channel=conda-forge mne
sometimes it went with

(py37) [root@xxx~]# conda create --name=mne --channel=conda-forge mne
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done

sometimes it stucked at the last step.

Now I always get an error called: couldn’t build the shadow program for solving msaa
I have no idea what this means, may you help with this?
here’s the code:

(mne) [root@xxx]# python -c "import mne; mne.sys_info()"
  % (environment_variable, parent_directory)
2022-02-15 09:57:09.922 (   5.963s) [        8BB101C0]   vtkShaderProgram.cxx:452    ERR| vtkShaderProgram (0x55fc3b3b9580): 1: 
2:   #version 140
3: #ifdef GL_ES
4: #ifdef GL_FRAGMENT_PRECISION_HIGH
5: precision highp float;
6: precision highp sampler2D;
7: precision highp sampler3D;
8: #else
9: precision mediump float;
10: precision mediump sampler2D;
11: precision mediump sampler3D;
12: #endif
13: #define texelFetchBuffer texelFetch
14: #define texture1D texture
15: #define texture2D texture
16: #define texture3D texture
17: #else // GL_ES
18: #define highp
19: #define mediump
20: #define lowp
21: #if __VERSION__ == 150
22: #define texelFetchBuffer texelFetch
23: #define texture1D texture
24: #define texture2D texture
25: #define texture3D texture
26: #endif
27: #endif // GL_ES
28: #define varying in
29: 
30:   in vec2 texCoord;
31:   uniform sampler2DMS tex;
32:   uniform int samplecount;
33:   out vec4 fragOutput0;
34: 
35: 
36:   void main()
37:   {
38:     float gamma = 2.2;
39: 
40:     // for each sample in the multi sample buffer...
41:     ivec2 itexcoords = ivec2(floor(textureSize(tex) * texCoord));
42:     vec3 accumulate = vec3(0.0,0.0,0.0);
43:     float alpha = 0.0;
44: 
45:     for (int i = 0; i < samplecount; i++)
46:     {
47:       vec4 sample = texelFetch(tex, itexcoords, i);
48:       // apply gamma correction and sum
49:       accumulate += pow(sample.rgb, vec3(gamma));
50:       alpha += sample.a;
51:     }
52: 
53:     // divide and reverse gamma correction
54:     accumulate /= float(samplecount);
55:     fragOutput0 = vec4(pow(accumulate, vec3(1.0/gamma)), alpha/float(samplecount));
56:   }
57:   

ERROR:root:1: 
2022-02-15 09:57:09.924 (   5.964s) [        8BB101C0]   vtkShaderProgram.cxx:453    ERR| vtkShaderProgram (0x55fc3b3b9580): 0:31(22): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'

ERROR:root:error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'
2022-02-15 09:57:09.924 (   5.964s) [        8BB101C0]vtkOpenGLVertexArrayObj:265    ERR| vtkOpenGLVertexArrayObject (0x55fc3b3f1ae0): attempt to add attribute without a program for attribute ndCoordIn
ERROR:root:attempt to add attribute without a program for attribute ndCoordIn
2022-02-15 09:57:09.924 (   5.964s) [        8BB101C0]vtkOpenGLQuadHelper.cxx:62    WARN| Error binding ndCoords to VAO.
2022-02-15 09:57:09.924 (   5.964s) [        8BB101C0]vtkOpenGLRenderWindow.c:1102   ERR| vtkXOpenGLRenderWindow (0x55fc3a8093a0): Couldn't build the shader program for resolving msaa.
ERROR:root:Couldn't build the shader program for resolving msaa.
Platform:       Linux-5.10.60-9.al8.x86_64-x86_64-with-centos-3-Soaring_Falcon
Python:         3.7.11 (default, Jul 27 2021, 14:32:16)  [GCC 7.5.0]
Executable:     /opt/miniconda3/envs/mne/bin/python
CPU:            x86_64: 2 cores
Memory:         Unavailable (requires "psutil" package)
mne:            0.24.1
numpy:          1.21.5 {blas=openblas, lapack=openblas}
scipy:          1.7.3
matplotlib:     3.5.1 {backend=QtAgg}

sklearn:        1.0.2
numba:          0.55.1
nibabel:        3.2.2
nilearn:        0.9.0
dipy:           1.4.1
cupy:           Not found
pandas:         1.3.5
mayavi:         4.7.4
pyvista:        0.33.2 {OpenGL 3.1 Mesa 20.3.3 via llvmpipe (LLVM 11.0.0, 256 bits)}
pyvistaqt:      0.7.0
ipyvtklink:     0.2.2
vtk:            9.1.0
PyQt5:          5.15.6
ipympl:         0.8.7
mne_qt_browser: 0.1.7
pooch:          v1.6.0
QLibraryPrivate::unload succeeded on "/opt/miniconda3/envs/mne/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" 
QLibraryPrivate::unload succeeded on "/opt/miniconda3/envs/mne/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" 
QLibraryPrivate::unload succeeded on "Xcursor" (faked)


MNE-Python 0.24+ no longer uses PySurfer, you must be on an old unsupported version. You should use the mne.viz.Brain class instead nowadays

Also, it looks like you might be on a headless display/system, consider setting up Xvfb for rendering capabilities. See Advanced setup — MNE 1.6.0 documentation for example