ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

NameError on import of mayavi.api (nan in tvtk/tvtk_classes.zip/tvtk_classes/render_window_interactor.py) #10985

Open grelston opened 5 years ago

grelston commented 5 years ago

Actual Behavior

>>> import mayavi.api
Traceback (most recent call last):
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\tvtk_helper.py", line 23, in get_module
ModuleNotFoundError: No module named 'tvtk.custom.generic_render_window_interactor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\mayavi\api.py", line 2, in <module>
    from mayavi.core.engine import Engine
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\mayavi\core\engine.py", line 28, in <module>
    from mayavi.core.base import Base
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\mayavi\core\base.py", line 19, in <module>
    from tvtk.pyface.tvtk_scene import TVTKScene
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\pyface\tvtk_scene.py", line 44, in <module>
    class TVTKScene(HasPrivateTraits):
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\pyface\tvtk_scene.py", line 175, in TVTKScene
    interactor = Property(Instance(tvtk.GenericRenderWindowInteractor))
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\tvtk_helper.py", line 494, in <lambda>
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\tvtk_helper.py", line 47, in get_class
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\tvtk_helper.py", line 28, in get_module
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\generic_render_window_interactor.py", line 29, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\render_window_interactor.py", line 32, in <module>
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\render_window_interactor.py", line 446, in RenderWindowInteractor
NameError: name 'nan' is not defined

Expected Behavior

>>> import mayavi.api
>>> 

Steps to Reproduce

  1. Setup a conda environment and install mayavi (see the Steps to Reproduce in #10984)
  2. Clean up the CRCRLF line-endings (e.g. by following these steps: https://github.com/ContinuumIO/anaconda-issues/issues/10984#issuecomment-499454605)
  3. Start Python and import mayavi:
(mayavi) C:\Users\User>python
Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import mayavi.api
Traceback (most recent call last):
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\tvtk_helper.py", line 23, in get_module
ModuleNotFoundError: No module named 'tvtk.custom.generic_render_window_interactor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\mayavi\api.py", line 2, in <module>
    from mayavi.core.engine import Engine
[snip]
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\render_window_interactor.py", line 32, in <module>
  File "C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\render_window_interactor.py", line 446, in RenderWindowInteractor
NameError: name 'nan' is not defined
Anaconda or Miniconda version:

Miniconda3-4.6.14-Windows-x86

Operating System:

Windows 7 Enterprise, Service Pack 1, 64-bit Operating System

conda info
``` active environment : mayavi active env location : C:\Miniconda3\envs\mayavi shell level : 2 user config file : C:\Users\User\.condarc populated config files : C:\Users\User\.condarc conda version : 4.6.14 conda-build version : not installed python version : 3.7.2.final.0 base environment : C:\Miniconda3 (writable) channel URLs : https://conda.anaconda.org/r/win-32 https://conda.anaconda.org/r/noarch https://repo.anaconda.com/pkgs/main/win-32 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-32 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/win-32 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-32 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\Miniconda3\pkgs C:\Users\User\.conda\pkgs C:\Users\User\AppData\Local\conda\conda\pkgs envs directories : C:\Miniconda3\envs C:\Users\User\.conda\envs C:\Users\User\AppData\Local\conda\conda\envs platform : win-32 user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.2 Windows/7 Windows/6.1.7601 administrator : True netrc file : None offline mode : False ```
conda list --show-channel-urls
``` # packages in environment at C:\Miniconda3\envs\mayavi: # # Name Version Build Channel apptools 4.4.0 py37_1 defaults blas 1.0 mkl defaults bzip2 1.0.6 hfa6e2cd_5 defaults ca-certificates 2019.5.15 0 defaults certifi 2019.3.9 py37_0 defaults configobj 5.0.6 py37_1 defaults curl 7.64.1 h2a8f88b_0 defaults envisage 4.7.2 py_0 defaults expat 2.2.5 he025d50_0 defaults freetype 2.9.1 ha9979f8_1 defaults future 0.17.1 py37_0 defaults hdf4 4.2.13 hf3d92eb_2 defaults hdf5 1.10.4 h7ebc959_0 defaults icc_rt 2019.0.0 h0cc432a_1 defaults icu 58.2 h3fcc66b_1 defaults intel-openmp 2019.4 245 defaults jpeg 9b he27b436_2 defaults jsoncpp 1.8.4 h74a9793_0 defaults krb5 1.16.1 hc04afaa_7 defaults libcurl 7.64.1 h2a8f88b_0 defaults libiconv 1.15 hc4a7105_7 defaults libnetcdf 4.6.1 h411e497_2 defaults libpng 1.6.37 h2a8f88b_0 defaults libssh2 1.8.2 h7a1dbc1_0 defaults libtiff 4.0.10 hb898794_2 defaults libxml2 2.9.9 h464c3ec_0 defaults lz4-c 1.8.1.2 h2fa13f4_0 defaults mayavi 4.6.2 py37h3ccff09_4 defaults mkl 2019.4 245 defaults mkl_fft 1.0.12 py37h14836fe_0 defaults mkl_random 1.0.2 py37h343c172_0 defaults mock 3.0.5 py37_0 defaults nose 1.3.7 py37_2 defaults numpy 1.16.4 py37h19fb1c0_0 defaults numpy-base 1.16.4 py37hc3f5095_0 defaults openssl 1.1.1c he774522_1 defaults pip 19.1.1 py37_0 defaults pyface 6.0.0 py37_0 defaults pygments 2.4.0 py_0 defaults pyqt 5.9.2 py37h6538335_0 defaults python 3.7.3 h8c8aaf0_1 defaults qt 5.9.7 vc14h73c81de_0 defaults setuptools 41.0.1 py37_0 defaults sip 4.19.8 py37h6538335_0 defaults six 1.12.0 py37_0 defaults sqlite 3.28.0 he774522_0 defaults tbb 2019.4 h74a9793_0 defaults tk 8.6.8 hfa6e2cd_0 defaults traits 5.1.1 py37he774522_0 defaults traitsui 6.0.0 py37_1 defaults vc 14.1 h0510ff6_4 defaults vs2015_runtime 14.15.26706 h3a45250_4 defaults vtk 8.2.0 py37h1e53df8_200 defaults wheel 0.33.4 py37_0 defaults wincertstore 0.2 py37_0 defaults xz 5.2.4 h2fa13f4_4 defaults zlib 1.2.11 h62dcd97_3 defaults zstd 1.3.7 h508b16e_0 defaults ```
grelston commented 5 years ago

Steps to fix the NameError

(base) C:\Users\User>conda activate mayavi

(mayavi) C:\Users\User>python
Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir(r'C:\Miniconda3\envs\mayavi\lib\site-packages\tvtk')
>>> import zipfile
>>> zipfile.ZipFile('tvtk_classes.zip').extractall()
>>> rwi_str = open('tvtk_classes/render_window_interactor.py', 'rt').read()
>>> open('tvtk_classes/render_window_interactor.py.orig', 'wt').write(rwi_str)
53516
>>> open('tvtk_classes/render_window_interactor.py', 'wt').write(rwi_str.replace('value=(0.0, nan)', 'value=(0.0, 0.0)'))
53516
>>> ^Z

(Restart python to clear the module cache)

(mayavi) C:\Users\User>python
Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import mayavi.api
>>> import tvtk.tvtk_classes
>>> tvtk.tvtk_classes.render_window_interactor
<module 'tvtk.tvtk_classes.render_window_interactor' from 'C:\\Miniconda3\\envs\\mayavi\\lib\\site-packages\\tvtk\\tvtk_classes\\render_window_interactor.py'>
>>>
grelston commented 5 years ago

I suspect this is an issue with the conda build of https://github.com/enthought/mayavi/tree/master/tvtk because a pip install of mayavi (and its apptools and envisage dependencies) works as expected.

Create a conda environment with many mayavi dependencies

(base) C:\Users\User>conda create --name mayavi-pip python=3.7 vtk numpy traitsui configobj six
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Miniconda3\envs\mayavi-pip

  added / updated specs:
    - configobj
    - numpy
    - python=3.7
    - six
    - traitsui
    - vtk

The following NEW packages will be INSTALLED:
```bash blas pkgs/main/win-32::blas-1.0-mkl bzip2 pkgs/main/win-32::bzip2-1.0.6-hfa6e2cd_5 ca-certificates pkgs/main/win-32::ca-certificates-2019.5.15-0 certifi pkgs/main/win-32::certifi-2019.3.9-py37_0 configobj pkgs/main/win-32::configobj-5.0.6-py37_1 curl pkgs/main/win-32::curl-7.64.1-h2a8f88b_0 expat pkgs/main/win-32::expat-2.2.5-he025d50_0 freetype pkgs/main/win-32::freetype-2.9.1-ha9979f8_1 future pkgs/main/win-32::future-0.17.1-py37_0 hdf4 pkgs/main/win-32::hdf4-4.2.13-hf3d92eb_2 hdf5 pkgs/main/win-32::hdf5-1.10.4-h7ebc959_0 icc_rt pkgs/main/win-32::icc_rt-2019.0.0-h0cc432a_1 intel-openmp pkgs/main/win-32::intel-openmp-2019.4-245 jpeg pkgs/main/win-32::jpeg-9b-he27b436_2 jsoncpp pkgs/main/win-32::jsoncpp-1.8.4-h74a9793_0 krb5 pkgs/main/win-32::krb5-1.16.1-hc04afaa_7 libcurl pkgs/main/win-32::libcurl-7.64.1-h2a8f88b_0 libiconv pkgs/main/win-32::libiconv-1.15-hc4a7105_7 libnetcdf pkgs/main/win-32::libnetcdf-4.6.1-h411e497_2 libpng pkgs/main/win-32::libpng-1.6.37-h2a8f88b_0 libssh2 pkgs/main/win-32::libssh2-1.8.2-h7a1dbc1_0 libtiff pkgs/main/win-32::libtiff-4.0.10-hb898794_2 libxml2 pkgs/main/win-32::libxml2-2.9.9-h464c3ec_0 lz4-c pkgs/main/win-32::lz4-c-1.8.1.2-h2fa13f4_0 mkl pkgs/main/win-32::mkl-2019.4-245 mkl_fft pkgs/main/win-32::mkl_fft-1.0.12-py37h14836fe_0 mkl_random pkgs/main/win-32::mkl_random-1.0.2-py37h343c172_0 numpy pkgs/main/win-32::numpy-1.16.4-py37h19fb1c0_0 numpy-base pkgs/main/win-32::numpy-base-1.16.4-py37hc3f5095_0 openssl pkgs/main/win-32::openssl-1.1.1c-he774522_1 pip pkgs/main/win-32::pip-19.1.1-py37_0 pyface pkgs/main/win-32::pyface-6.0.0-py37_0 pygments pkgs/main/noarch::pygments-2.4.0-py_0 python pkgs/main/win-32::python-3.7.3-h8c8aaf0_1 setuptools pkgs/main/win-32::setuptools-41.0.1-py37_0 six pkgs/main/win-32::six-1.12.0-py37_0 sqlite pkgs/main/win-32::sqlite-3.28.0-he774522_0 tbb pkgs/main/win-32::tbb-2019.4-h74a9793_0 tk pkgs/main/win-32::tk-8.6.8-hfa6e2cd_0 traits pkgs/main/win-32::traits-5.1.1-py37he774522_0 traitsui pkgs/main/win-32::traitsui-6.0.0-py37_1 vc pkgs/main/win-32::vc-14.1-h0510ff6_4 vs2015_runtime pkgs/main/win-32::vs2015_runtime-14.15.26706-h3a45250_4 vtk pkgs/main/win-32::vtk-8.2.0-py37h1e53df8_200 wheel pkgs/main/win-32::wheel-0.33.4-py37_0 wincertstore pkgs/main/win-32::wincertstore-0.2-py37_0 xz pkgs/main/win-32::xz-5.2.4-h2fa13f4_4 zlib pkgs/main/win-32::zlib-1.2.11-h62dcd97_3 zstd pkgs/main/win-32::zstd-1.3.7-h508b16e_0 ```
Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate mayavi-pip
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Use pip to install mayavi, apptools, and envisage

(base) C:\Users\User>conda activate mayavi-pip

(mayavi-pip) C:\Users\User>pip --no-cache-dir install mayavi
```bash Collecting mayavi Downloading https://files.pythonhosted.org/packages/83/9e/293ba57353ed258c2f64d54bf00ca1447c1f38f4eb60d0e762ddec57bf51/mayavi-4.6.2.tar.bz2 (7.0MB) |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 7.0MB 3.2MB/s Collecting apptools (from mayavi) Downloading https://files.pythonhosted.org/packages/78/84/64764e2c87fcb7ad7521bdabc7c44c109b80691f94218cbddd5df2ee682c/apptools-4.4.0.tar.bz2 (241kB) |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 245kB 312kB/s Collecting envisage (from mayavi) Downloading https://files.pythonhosted.org/packages/24/25/63a50574fd9af66345ee6dc0d4bac342e755f9ac868927ca0beae178725a/envisage-4.7.2.tar.gz (256kB) |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 266kB 218kB/s Requirement already satisfied: numpy in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (1.16.4) Requirement already satisfied: pyface>=6.0.0 in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (6.0.0) Requirement already satisfied: pygments in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (2.4.0) Requirement already satisfied: traits>=4.6.0 in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (5.1.1) Requirement already satisfied: traitsui>=6.0.0 in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (6.0.0) Requirement already satisfied: vtk in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from mayavi) (-PKG-VERSION) Requirement already satisfied: configobj in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from apptools->mayavi) (5.0.6) Requirement already satisfied: six in c:\miniconda3\envs\mayavi-pip\lib\site-packages (from traits>=4.6.0->mayavi) (1.12.0) Building wheels for collected packages: mayavi, apptools, envisage Building wheel for mayavi (setup.py) ... done Stored in directory: C:\Users\User\AppData\Local\Temp\pip-ephem-wheel-cache-13iqlfgp\wheels\59\49 \db\14986f88cce0c66019c64ed57d47536c510efa999e504f378e Building wheel for apptools (setup.py) ... done Stored in directory: C:\Users\User\AppData\Local\Temp\pip-ephem-wheel-cache-13iqlfgp\wheels\f9\9e \2a\981bab2267d8f7fa546568cd79440e6b61b4fc570ee071080e Building wheel for envisage (setup.py) ... done Stored in directory: C:\Users\User\AppData\Local\Temp\pip-ephem-wheel-cache-13iqlfgp\wheels\c6\4e \b1\7fdc3b4f5d86e82f74e962ec368bd024d91105aee07b2e5c90 ```
Successfully built mayavi apptools envisage
Installing collected packages: apptools, envisage, mayavi
Successfully installed apptools-4.4.0 envisage-4.7.2 mayavi-4.6.2

Confirm that pip-installed mayavi works as expected

(mayavi-pip) C:\Users\User>python
Python 3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)] :: Anaconda, Inc. on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import mayavi.api
>>> import tvtk.tvtk_classes
>>> tvtk.tvtk_classes.render_window_interactor
<module 'tvtk.tvtk_classes.render_window_interactor' from 'C:\\Miniconda3\\envs\\mayavi-pip\\lib\\si
te-packages\\tvtk\\tvtk_classes.zip\\tvtk_classes\\render_window_interactor.pyc'>
>>>