enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Blank mayavi.mlab scene #1018

Open matthiasfabry opened 3 years ago

matthiasfabry commented 3 years ago

I created a fresh conda environment with: conda create -n pymayavi python=3.7 vtk=8 pyqt=5 then conda activate pymayavi conda install mayavi This creates an environment with:

$ conda list:
# packages in environment at /Users/matthiasf/opt/miniconda3/envs/pymayavi:
#
# Name                    Version                   Build  Channel
apptools                  5.1.0              pyh44b312d_0    conda-forge
bzip2                     1.0.8                hc929b4f_4    conda-forge
c-ares                    1.17.1               h0d85af4_1    conda-forge
ca-certificates           2020.12.5            h033912b_0    conda-forge
certifi                   2020.12.5        py37hf985489_1    conda-forge
configobj                 5.0.6                      py_0    conda-forge
curl                      7.75.0               h06286d4_0    conda-forge
dbus                      1.13.6               h0c50699_1    conda-forge
envisage                  4.9.2              pyh9f0ad1d_1    conda-forge
expat                     2.2.10               h1c7c35f_0    conda-forge
freetype                  2.10.4               h4cff582_1    conda-forge
future                    0.18.2           py37hf985489_3    conda-forge
gettext                   0.19.8.1          h7937167_1005    conda-forge
glib                      2.66.7               he49afe7_1    conda-forge
glib-tools                2.66.7               he49afe7_1    conda-forge
hdf4                      4.2.13            h71d84a9_1004    conda-forge
hdf5                      1.10.6          nompi_h34ad4e8_1111    conda-forge
icu                       64.2                 h6de7cb9_1    conda-forge
jpeg                      9d                   hbcb3906_0    conda-forge
jsoncpp                   1.8.4             ha1b3eb9_1002    conda-forge
krb5                      1.17.2               h60d9502_0    conda-forge
libblas                   3.9.0                8_openblas    conda-forge
libcblas                  3.9.0                8_openblas    conda-forge
libcurl                   7.75.0               h8ef9fac_0    conda-forge
libcxx                    11.1.0               habf9029_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 haf1e3a3_1    conda-forge
libffi                    3.3                  h046ec9c_2    conda-forge
libgfortran               4.0.0           7_5_0_h1a10cd1_19    conda-forge
libgfortran4              7.5.0               h1a10cd1_19    conda-forge
libglib                   2.66.7               hd556434_1    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
liblapack                 3.9.0                8_openblas    conda-forge
libnetcdf                 4.7.4           nompi_h9d8a93f_107    conda-forge
libnghttp2                1.43.0               h07e645a_0    conda-forge
libopenblas               0.3.12          openmp_h63d9170_1    conda-forge
libpng                    1.6.37               h7cec526_2    conda-forge
libssh2                   1.9.0                h8a08a2b_5    conda-forge
libtiff                   4.2.0                h355d032_0    conda-forge
libwebp-base              1.2.0                hbcf498f_0    conda-forge
libxml2                   2.9.10               h53d96d6_0    conda-forge
llvm-openmp               11.0.1               h7c73e74_0    conda-forge
lz4-c                     1.9.2                hb1e8313_3    conda-forge
mayavi                    4.7.2            py37h0231a1f_1    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
numpy                     1.20.1           py37ha9839cc_0    conda-forge
openssl                   1.1.1j               hbcf498f_0    conda-forge
pcre                      8.44                 hb1e8313_0    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
pyface                    7.3.0              pyh44b312d_0    conda-forge
pygments                  2.8.0              pyhd8ed1ab_0    conda-forge
pyqt                      5.9.2            py37h2a560b1_4    conda-forge
python                    3.7.10          h7728216_100_cpython    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
qt                        5.9.7                h8cf7e54_3    conda-forge
readline                  8.0                  h0678c8f_2    conda-forge
setuptools                49.6.0           py37hf985489_3    conda-forge
sip                       4.19.8           py37h0a44026_0  
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h17101e1_0    conda-forge
tbb                       2020.2               h940c156_4    conda-forge
tk                        8.6.10               h0419947_1    conda-forge
traits                    6.2.0            py37hf967b71_0    conda-forge
traitsui                  7.1.0              pyh9f0ad1d_0    conda-forge
vtk                       8.2.0           py37hd5eadda_218    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zlib                      1.2.11            h7795811_1010    conda-forge
zstd                      1.4.5                h41d2c2f_0  

Upon running a python mlab script (simply plotting a 3D point cloud with mlab.points3d()):

import mayavi.mlab as mlab
import numpy as np

data = np.array([[0, 0, 0], [1, 1, 1]])

mlab.figure()
mlab.points3d(data)
mlab.show()

this runs into ImportErrors of:

ModuleNotFoundError: No module named 'importlib_metadata'

and

ModuleNotFoundError: No module named 'importlib_resources'

After installing both of these, I still don't have a working mayavi.mlab environment, as the example above spawns a blank mayavi scene. The buttons on the top are unresponsive. Setting then the environment variables:

export QT_API=pyqt
export ETS_TOOLKIT=qt5

Results in:

RuntimeError: No pyface.toolkits plugin found for toolkit qt5

What might be the issue here?

It's weird as I remember this working a couple months ago (although, granted, I do not have the package list from that time).

prabhuramachandran commented 3 years ago

Just a quick question and some comments, why are you using VTK 8.2? I am not sure how the conda-forge mayavi package is built but if it is a wheel then it likely was built against a specific VTK version. I find that the most reliable way to get things working is to install VTK and mayavi via pip, that way you get VTK-9.x and Mayavi is then built for the version of VTK that you have installed. I am not sure what the Qt issues are. I did try conda recently for Python 3.8 but installed mayavi and vtk from pip and it all worked well for me.

matthiasfabry commented 3 years ago

Thanks for your quick reply. There is no particular reason I chose vtk 8, except that I've read around on the issues that there are some issues with vtk 9 and the later pythons.

anyway, I did as you say: conda create -n pymayavi python=3.8 conda activate pymayavi conda install pyqt pip install vtk pip install mayavi This indeed builds mayavi and vtk, but now, without the ETS env var, no scene even spawns. With the ETS env var, the same RuntimeError: No pyface.toolkits plugin found for toolkit qt5 happens

I now have:conda list

# packages in environment at /Users/matthiasf/opt/miniconda3/envs/pymayavi:
#
# Name                    Version                   Build  Channel
apptools                  5.1.0                    pypi_0    pypi
ca-certificates           2020.12.5            h033912b_0    conda-forge
certifi                   2020.12.5        py38h50d1736_1    conda-forge
configobj                 5.0.6                    pypi_0    pypi
dbus                      1.13.6               h0c50699_1    conda-forge
envisage                  5.0.0                    pypi_0    pypi
expat                     2.2.10               h1c7c35f_0    conda-forge
gettext                   0.19.8.1          h7937167_1005    conda-forge
glib                      2.66.7               he49afe7_1    conda-forge
glib-tools                2.66.7               he49afe7_1    conda-forge
icu                       68.1                 h74dc148_0    conda-forge
importlib-metadata        3.7.2                    pypi_0    pypi
importlib-resources       5.1.2                    pypi_0    pypi
jpeg                      9d                   hbcb3906_0    conda-forge
krb5                      1.17.2               h60d9502_0    conda-forge
libclang                  11.1.0          default_he082bbe_0    conda-forge
libcxx                    11.1.0               habf9029_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libffi                    3.3                  h046ec9c_2    conda-forge
libglib                   2.66.7               hd556434_1    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
libllvm11                 11.1.0               hd011deb_0    conda-forge
libpng                    1.6.37               h7cec526_2    conda-forge
libpq                     13.1                 h052a64a_2    conda-forge
lz4-c                     1.9.3                h046ec9c_0    conda-forge
mayavi                    4.7.2                    pypi_0    pypi
mysql-common              8.0.23               h694c41f_1    conda-forge
mysql-libs                8.0.23               hbeb7981_1    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
nspr                      4.29                 hbc8d48c_1    conda-forge
nss                       3.47                 hc0980d9_0    conda-forge
numpy                     1.20.1                   pypi_0    pypi
openssl                   1.1.1j               hbcf498f_0    conda-forge
pcre                      8.44                 hb1e8313_0    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
pyface                    7.3.0                    pypi_0    pypi
pygments                  2.8.1                    pypi_0    pypi
pyqt                      5.12.3           py38h50d1736_7    conda-forge
pyqt-impl                 5.12.3           py38h721a93c_7    conda-forge
pyqt5-sip                 4.19.18          py38h5745d40_7    conda-forge
pyqtchart                 5.12             py38h721a93c_7    conda-forge
pyqtwebengine             5.12.1           py38h721a93c_7    conda-forge
python                    3.8.8           h4e93d89_0_cpython    conda-forge
python_abi                3.8                      1_cp38    conda-forge
qt                        5.12.9               h126340a_4    conda-forge
readline                  8.0                  h0678c8f_2    conda-forge
setuptools                49.6.0           py38h50d1736_3    conda-forge
six                       1.15.0                   pypi_0    pypi
sqlite                    3.34.0               h17101e1_0    conda-forge
tk                        8.6.10               h0419947_1    conda-forge
traits                    6.2.0                    pypi_0    pypi
traitsui                  7.1.1                    pypi_0    pypi
vtk                       9.0.1                    pypi_0    pypi
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zipp                      3.4.1                    pypi_0    pypi
zlib                      1.2.11            h7795811_1010    conda-forge
zstd                      1.4.9                h582d3a0_0    conda-forge
matthiasfabry commented 3 years ago

This does seem to be a qt or pyface issue. No matter where I install vtk/pyqt or mayavi from, I still hit the RuntimeError: No pyface.toolkits plugin found for toolkit qt5 error. I've looked in the pyface/base_toolkit.py file and printed the available toolkits from the entrypoint pyface.toolkits:

(EntryPoint(name='null', value='pyface.ui.null.init:toolkit_object', group='pyface.toolkits'), EntryPoint(name='qt', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'), EntryPoint(name='qt4', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'), EntryPoint(name='wx', value='pyface.ui.wx.init:toolkit_object', group='pyface.toolkits'))

Obviously, no qt5 to be found in this list, hence the Exception. However I find qt4 is listed here, which is not even installed, qt5.12.9 and pyqt5.12.3 are installed. Is it possible this piece of toolkit linking needs to be updated, or did I not install pyface from the correct repo?

BTW: using ETS_TOOLKIT=wx, which is listed in the available toolkit, does not solve my problem, as then

RuntimeError: No pyface.toolkits plugin could be loaded for wx

It fails to load properly.

matthiasfabry commented 3 years ago

After some more trial and error using different installation channels and reverting to python3.6, I finally get a satisfactory mlab interface again.

now I have:

conda list:

apptools                  5.1.0                    pypi_0    pypi
blas                      1.0                         mkl  
ca-certificates           2021.1.19            hecd8cb5_1  
certifi                   2020.12.5        py36hecd8cb5_0  
configobj                 5.0.6                    pypi_0    pypi
envisage                  5.0.0                    pypi_0    pypi
importlib-metadata        2.0.0                      py_1  
importlib_metadata        2.0.0                         1  
importlib_resources       5.1.2            py36hecd8cb5_1  
intel-openmp              2019.4                      233  
libcxx                    10.0.0                        1  
libedit                   3.1.20191231         h1de35cc_1  
libffi                    3.3                  hb1e8313_2  
libgfortran               3.0.1                h93005f0_2  
mayavi                    4.7.2                    pypi_0    pypi
mkl                       2019.4                      233  
mkl-service               2.3.0            py36h9ed2024_0  
mkl_fft                   1.3.0            py36ha059aab_0  
mkl_random                1.1.1            py36h959d312_0  
ncurses                   6.2                  h0a44026_1  
numpy                     1.19.2           py36h456fd55_0  
numpy-base                1.19.2           py36hcfb5961_0  
openssl                   1.1.1j               h9ed2024_0  
pip                       21.0.1           py36hecd8cb5_0  
pyface                    7.3.0                    pypi_0    pypi
pygments                  2.8.1                    pypi_0    pypi
pyqt5                     5.15.4                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.8.1                   pypi_0    pypi
python                    3.6.13               h88f2d9e_0  
python.app                3                py36h9ed2024_0  
readline                  8.1                  h9ed2024_0  
scipy                     1.5.2            py36h912ce22_0  
setuptools                52.0.0           py36hecd8cb5_0  
six                       1.15.0           py36hecd8cb5_0  
sqlite                    3.33.0               hffcf06c_0  
tk                        8.6.10               hb0a8c7a_0  
traits                    6.2.0                    pypi_0    pypi
traitsui                  7.1.1                    pypi_0    pypi
vtk                       9.0.1                    pypi_0    pypi
wheel                     0.36.2             pyhd3eb1b0_0  
xz                        5.2.5                h1de35cc_0  
zipp                      3.4.0              pyhd3eb1b0_0  
zlib                      1.2.11               h1de35cc_3  

and have no environment variables (ETS_TOOLKIT/QT_API) set. What ended up working is using pip install mayavi (even though the wheel building failed, the installation was somehow succesfull). I wouldn't say this was an easy or straightforward process. I would propose to consolidate a built wheel to conda-forge so less knowledgable/persevering data scientists can just conda install mayavi and have a working mayavi interface from python. But for me at least this issue is solved, and may be closed.

jeffrey-cochran commented 1 year ago

I'm jumping through similar hoops...

wdevazelhes commented 10 months ago

🎉 I did the same steps as @matthiasfabry just above (i.e. I obtained a similar conda list output, by creating a new python 3.6 conda env, installing numpy and scipy through conda, and installing vtk, pyqt5, pyface, and mayavi through pip), and also wheels building failed, though for me mayavi didn't work then, but what solved it was installing an older vtk as per here: https://anhquancao.github.io/blog/2022/how-to-install-mayavi-with-python-3-on-ubuntu-2004-using-pip-or-anaconda/

here is my conda list

# Name                    Version                   Build  Channel
apptools                  5.2.1                    pypi_0    pypi
blas                      1.0                         mkl  
ca-certificates           2023.08.22           hecd8cb5_0  
certifi                   2021.5.30        py36hecd8cb5_0  
configobj                 5.0.8                    pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
envisage                  6.1.1                    pypi_0    pypi
importlib-metadata        4.8.3                    pypi_0    pypi
importlib-resources       5.4.0                    pypi_0    pypi
intel-openmp              2023.1.0         ha357a0b_43547  
kiwisolver                1.3.1                    pypi_0    pypi
libcxx                    14.0.6               h9765a3e_0  
libffi                    3.3                  hb1e8313_2  
libgfortran               3.0.1                h93005f0_2  
matplotlib                3.3.4                    pypi_0    pypi
mayavi                    4.8.0                    pypi_0    pypi
mkl                       2019.4                      233  
mkl-service               2.3.0            py36h9ed2024_0  
mkl_fft                   1.3.0            py36ha059aab_0  
mkl_random                1.1.1            py36h959d312_0  
ncurses                   6.4                  hcec6c5f_0  
numpy                     1.19.2           py36h456fd55_0  
numpy-base                1.19.2           py36hcfb5961_0  
openssl                   1.1.1w               hca72f7f_0  
pillow                    8.4.0                    pypi_0    pypi
pip                       21.2.2           py36hecd8cb5_0  
pyface                    7.4.4                    pypi_0    pypi
pygments                  2.14.0                   pypi_0    pypi
pyparsing                 3.1.1                    pypi_0    pypi
pyqt5                     5.15.6                   pypi_0    pypi
pyqt5-qt5                 5.15.11                  pypi_0    pypi
pyqt5-sip                 12.9.1                   pypi_0    pypi
python                    3.6.13               h88f2d9e_0  
python-dateutil           2.8.2                    pypi_0    pypi
readline                  8.2                  hca72f7f_0  
scipy                     1.5.2            py36h912ce22_0  
setuptools                58.0.4           py36hecd8cb5_0  
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.41.2               h6c40b1e_0  
tk                        8.6.12               h5d9f67b_0  
traits                    6.4.1                    pypi_0    pypi
traitsui                  7.4.3                    pypi_0    pypi
typing-extensions         4.1.1                    pypi_0    pypi
vtk                       8.1.2                    pypi_0    pypi
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.4.2                h6c40b1e_0  
zipp                      3.6.0                    pypi_0    pypi
zlib                      1.2.13               h4dc903c_0