conda-forge / vtk-feedstock

A conda-smithy repository for vtk.
BSD 3-Clause "New" or "Revised" License
13 stars 64 forks source link

Can't import vtk with latest build (211) #114

Closed milljm closed 4 years ago

milljm commented 4 years ago

Issue: Can not import VTK (for Python 3.7, 3.8. Have not tested 3.6):

>>> import vtk
Traceback (most recent call last):
  File "/Users/me/libs/miniconda/envs/vtk_test/lib/python3.7/site-packages/vtkmodules/vtkIOExodus.py", line 5, in <module>
    from .vtkIOExodusPython import *
ImportError: dlopen(/Users/me/libs/miniconda/envs/vtk_test/lib/python3.7/site-packages/vtkmodules/vtkIOExodusPython.so, 2): Library not loaded: @rpath/libnetcdf.15.dylib
  Referenced from: /Users/me/libs/miniconda/envs/vtk_test/lib/libvtkexodusII-8.2.1.dylib
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/libs/miniconda/envs/vtk_test/lib/python3.7/site-packages/vtk.py", line 32, in <module>
    all_spec.loader.exec_module(all_m)
  File "/Users/me/libs/miniconda/envs/vtk_test/lib/python3.7/site-packages/vtkmodules/all.py", line 70, in <module>
    from .vtkIOExodus import *
  File "/Users/me/libs/miniconda/envs/vtk_test/lib/python3.7/site-packages/vtkmodules/vtkIOExodus.py", line 9, in <module>
    from vtkIOExodusPython import *
ModuleNotFoundError: No module named 'vtkIOExodusPython'


Environment (conda list):

``` $ conda list # packages in environment at /Users/me/libs/miniconda/envs/vtk_test: # # Name Version Build Channel bzip2 1.0.8 h0b31af3_2 conda-forge ca-certificates 2019.11.28 hecc5488_0 conda-forge certifi 2019.11.28 py37hc8dfbb8_1 conda-forge curl 7.68.0 h8754def_0 conda-forge expat 2.2.9 h4a8c4bd_2 conda-forge freetype 2.10.1 h8da9a1a_0 conda-forge future 0.18.2 py37hc8dfbb8_1 conda-forge hdf4 4.2.13 h84186c3_1003 conda-forge hdf5 1.10.5 nompi_h3e39495_1104 conda-forge icu 64.2 h6de7cb9_1 conda-forge jpeg 9c h1de35cc_1001 conda-forge jsoncpp 1.8.4 ha1b3eb9_1002 conda-forge krb5 1.16.4 h1752a42_0 conda-forge libcurl 7.68.0 h709d2b2_0 conda-forge libcxx 9.0.1 1 conda-forge libedit 3.1.20170329 hcfe32e1_1001 conda-forge libffi 3.2.1 h4a8c4bd_1007 conda-forge libgfortran 4.0.0 2 conda-forge libiconv 1.15 h0b31af3_1006 conda-forge libnetcdf 4.7.4 nompi_he461dc0_101 conda-forge libpng 1.6.37 hbbe82c9_1 conda-forge libssh2 1.8.2 hcdc9a53_2 conda-forge libtiff 4.1.0 h2ae36a8_6 conda-forge libwebp-base 1.1.0 h0b31af3_3 conda-forge libxml2 2.9.10 h53d96d6_0 conda-forge llvm-openmp 9.0.1 h28b9765_2 conda-forge lz4-c 1.8.3 h6de7cb9_1001 conda-forge ncurses 6.1 h0a44026_1002 conda-forge openssl 1.1.1e h0b31af3_0 conda-forge pip 20.0.2 py_2 conda-forge python 3.7.6 h90870a6_5_cpython conda-forge python_abi 3.7 1_cp37m conda-forge readline 8.0 hcfe32e1_0 conda-forge setuptools 46.1.3 py37hc8dfbb8_0 conda-forge sqlite 3.30.1 h93121df_0 conda-forge tbb 2019.9 ha1b3eb9_1 conda-forge tk 8.6.10 hbbe82c9_0 conda-forge vtk 8.2.0 py37he9ad749_211 conda-forge wheel 0.34.2 py_1 conda-forge xz 5.2.4 h0b31af3_1002 conda-forge zlib 1.2.11 h0b31af3_1006 conda-forge zstd 1.4.4 hed8d7c8_2 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : vtk_test active env location : /Users/me/libs/miniconda/envs/vtk_test shell level : 2 user config file : /Users/me/.condarc populated config files : /Users/me/.condarc conda version : 4.8.3 conda-build version : 3.19.0 python version : 3.7.6.final.0 virtual packages : __osx=10.15.3 base environment : /Users/me/libs/miniconda (writable) channel URLs : https://mooseframework.org/conda/moose/osx-64 https://mooseframework.org/conda/moose/noarch https://conda.anaconda.org/conda-forge/osx-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/osx-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/osx-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /Users/me/libs/miniconda/pkgs /Users/me/.conda/pkgs envs directories : /Users/me/libs/miniconda/envs /Users/me/.conda/envs platform : osx-64 user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.6 Darwin/19.3.0 OSX/10.15.3 UID:GID : 501:20 netrc file : None offline mode : False ```
xylar commented 4 years ago

@ocefpaf, is this consistent with the libnetcdf error you were addressing in https://github.com/conda-forge/libnetcdf-feedstock/pull/98? Do folks just need to wait for that build to get picked up with new conda create calls?

xylar commented 4 years ago

@ocefpaf, actually I see that this environment is with the new build:

libnetcdf                 4.7.4           nompi_he461dc0_101    conda-forge

That's discouraging.

ocefpaf commented 4 years ago

That's discouraging.

Indeed. I can reproduce that here. Not sure why vtk is breaking the run_exports though. It works as expected if I try to install nco or netcdf4. I'll try bumping the build here to see what happens.

ocefpaf commented 4 years ago

@beckermr and @isuruf I guess we'll have to do a repo patch for libnetcdf. I have never been successful to send one of those PRs though.

isuruf commented 4 years ago

I added some helper functions now. https://github.com/conda-forge/conda-forge-repodata-patches-feedstock/blob/master/recipe/gen_patch_json.py#L499

ocefpaf commented 4 years ago

I added some helper functions now. conda-forge/conda-forge-repodata-patches-feedstock:recipe/gen_patch_json.py@master#L499

Awesome! I'll try a PR and ping you there.

ocefpaf commented 4 years ago

Should be solved now.

CorbinFoucart commented 4 years ago

I am getting the exact same error message as the OP; following your steps and setting up a fresh conda environment, I'm able to import vtk. However, installing netcdf4 results in the error returning upon import...

The minimal environment setup is:

# run at top level directory after activating conda env
conda create -n vtk_test_env python=3.7
conda activate vtk_test_env

# base installs
conda install numpy scipy sympy matplotlib
conda install nb_conda 

# vtk
conda install -c conda-forge vtk

# the following line, if uncommented,
# results in the ModuleNotFoundError: No module named 'vtkIOExodusPython'
#conda install -c anaconda netcdf4 # clashes with VTK

If I need to use both the vtk and netcdf4 libraries, is there a workaround?

xylar commented 4 years ago

@CorbinFoucart, by mixing package versions between defaults and conda-forge, you are quite likely to get incompatible versions of the packages. It seems to me that you need to be getting all these packages from conda-forge if you are getting any of them from here:

conda config --set channel_priority strict
conda create -n vtk_test_env -c conda-forge python=3.7 numpy scipy sympy matplotlib nb_conda vtk netcdf4
conda activate vtk_test_env
python -c "import vtk"

Mixing libnetcdf from one channel with packages that rely on it from another channel will not work. This worked fine for me in a test on linux. Note below that all my packages are from conda-forge.

Environment (conda list):

``` $ conda list # packages in environment at /Users/me/libs/miniconda/envs/vtk_test: # # Name Version Build Channel $ conda list # packages in environment at /home/xylar/miniconda3/envs/test: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_llvm conda-forge attrs 19.3.0 py_0 conda-forge backcall 0.1.0 py_0 conda-forge bleach 3.1.4 pyh9f0ad1d_0 conda-forge bzip2 1.0.8 h516909a_2 conda-forge ca-certificates 2020.4.5.1 hecc5488_0 conda-forge certifi 2020.4.5.1 py37hc8dfbb8_0 conda-forge cftime 1.1.1.2 py37h03ebfcd_0 conda-forge curl 7.68.0 hf8cf82a_0 conda-forge cycler 0.10.0 py_2 conda-forge dbus 1.13.6 he372182_0 conda-forge decorator 4.4.2 py_0 conda-forge defusedxml 0.6.0 py_0 conda-forge entrypoints 0.3 py37hc8dfbb8_1001 conda-forge expat 2.2.9 he1b5a44_2 conda-forge fastcache 1.1.0 py37h8f50634_1 conda-forge fontconfig 2.13.1 h86ecdb6_1001 conda-forge freetype 2.10.1 he06d7ca_0 conda-forge future 0.18.2 py37hc8dfbb8_1 conda-forge gettext 0.19.8.1 hc5be6a0_1002 conda-forge glib 2.58.3 py37he00f558_1003 conda-forge gmp 6.2.0 he1b5a44_2 conda-forge gmpy2 2.1.0b1 py37h04dde30_0 conda-forge gst-plugins-base 1.14.5 h0935bb2_2 conda-forge gstreamer 1.14.5 h36ae1b5_2 conda-forge hdf4 4.2.13 hf30be14_1003 conda-forge hdf5 1.10.5 nompi_h3c11f04_1104 conda-forge icu 64.2 he1b5a44_1 conda-forge importlib-metadata 1.6.0 py37hc8dfbb8_0 conda-forge importlib_metadata 1.6.0 0 conda-forge ipykernel 5.2.0 py37h43977f1_1 conda-forge ipython 7.13.0 py37hc8dfbb8_2 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jedi 0.16.0 py37hc8dfbb8_1 conda-forge jinja2 2.11.1 py_0 conda-forge jpeg 9c h14c3975_1001 conda-forge jsoncpp 1.8.4 hc9558a2_1002 conda-forge jsonschema 3.2.0 py37hc8dfbb8_1 conda-forge jupyter_client 6.1.2 py_0 conda-forge jupyter_core 4.6.3 py37hc8dfbb8_1 conda-forge kiwisolver 1.2.0 py37h99015e2_0 conda-forge krb5 1.16.4 h2fd8d38_0 conda-forge ld_impl_linux-64 2.34 h53a641e_0 conda-forge libblas 3.8.0 16_openblas conda-forge libcblas 3.8.0 16_openblas conda-forge libclang 9.0.1 default_hde54327_0 conda-forge libcurl 7.68.0 hda55be3_0 conda-forge libedit 3.1.20170329 hf8c457e_1001 conda-forge libffi 3.2.1 he1b5a44_1007 conda-forge libgcc-ng 9.2.0 h24d8f2e_2 conda-forge libgfortran-ng 7.3.0 hdf63c60_5 conda-forge libiconv 1.15 h516909a_1006 conda-forge liblapack 3.8.0 16_openblas conda-forge libllvm9 9.0.1 hc9558a2_0 conda-forge libnetcdf 4.7.4 nompi_h9f9fd6a_101 conda-forge libopenblas 0.3.9 h5ec1e0e_0 conda-forge libpng 1.6.37 hed695b0_1 conda-forge libsodium 1.0.17 h516909a_0 conda-forge libssh2 1.8.2 h22169c7_2 conda-forge libstdcxx-ng 9.2.0 hdf63c60_2 conda-forge libtiff 4.1.0 hc7e4089_6 conda-forge libuuid 2.32.1 h14c3975_1000 conda-forge libwebp-base 1.1.0 h516909a_3 conda-forge libxcb 1.13 h14c3975_1002 conda-forge libxkbcommon 0.10.0 he1b5a44_0 conda-forge libxml2 2.9.10 hee79883_0 conda-forge llvm-openmp 9.0.1 hc9558a2_2 conda-forge lz4-c 1.8.3 he1b5a44_1001 conda-forge markupsafe 1.1.1 py37h8f50634_1 conda-forge matplotlib 3.2.1 0 conda-forge matplotlib-base 3.2.1 py37h30547a4_0 conda-forge mistune 0.8.4 py37h516909a_1000 conda-forge mpc 1.1.0 h04dde30_1006 conda-forge mpfr 4.0.2 he80fd80_0 conda-forge mpmath 1.1.0 py_0 conda-forge nb_conda 2.2.1 py37_2 conda-forge nb_conda_kernels 2.2.3 py37_0 conda-forge nbconvert 5.6.1 py37_0 conda-forge nbformat 5.0.4 py_0 conda-forge ncurses 6.1 hf484d3e_1002 conda-forge netcdf4 1.5.3 nompi_py37hec16513_103 conda-forge notebook 6.0.3 py37_0 conda-forge nspr 4.25 he1b5a44_0 conda-forge nss 3.47 he751ad9_0 conda-forge numpy 1.18.1 py37h8960a57_1 conda-forge openssl 1.1.1f h516909a_0 conda-forge pandoc 2.9.2 0 conda-forge pandocfilters 1.4.2 py_1 conda-forge parso 0.6.2 py_0 conda-forge pcre 8.44 he1b5a44_0 conda-forge pexpect 4.8.0 py37hc8dfbb8_1 conda-forge pickleshare 0.7.5 py37hc8dfbb8_1001 conda-forge pip 20.0.2 py_2 conda-forge prometheus_client 0.7.1 py_0 conda-forge prompt-toolkit 3.0.5 py_0 conda-forge pthread-stubs 0.4 h14c3975_1001 conda-forge ptyprocess 0.6.0 py_1001 conda-forge pygments 2.6.1 py_0 conda-forge pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyqt 5.12.3 py37hcca6a23_1 conda-forge pyqt5-sip 4.19.18 pypi_0 pypi pyqtwebengine 5.12.1 pypi_0 pypi pyrsistent 0.16.0 py37h8f50634_0 conda-forge python 3.7.6 h8356626_5_cpython conda-forge python-dateutil 2.8.1 py_0 conda-forge python_abi 3.7 1_cp37m conda-forge pyzmq 19.0.0 py37hac76be4_1 conda-forge qt 5.12.5 hd8c4c69_1 conda-forge readline 8.0 hf8c457e_0 conda-forge scipy 1.4.1 py37ha3d9a3c_2 conda-forge send2trash 1.5.0 py_0 conda-forge setuptools 46.1.3 py37hc8dfbb8_0 conda-forge six 1.14.0 py_1 conda-forge sqlite 3.30.1 hcee41ef_0 conda-forge sympy 1.5.1 py37hc8dfbb8_3 conda-forge tbb 2020.1 hc9558a2_0 conda-forge terminado 0.8.3 py37hc8dfbb8_1 conda-forge testpath 0.4.4 py_0 conda-forge tk 8.6.10 hed695b0_0 conda-forge tornado 6.0.4 py37h8f50634_1 conda-forge traitlets 4.3.3 py37hc8dfbb8_1 conda-forge vtk 8.2.0 py37h55fc74f_213 conda-forge wcwidth 0.1.9 pyh9f0ad1d_0 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.34.2 py_1 conda-forge xorg-kbproto 1.0.7 h14c3975_1002 conda-forge xorg-libice 1.0.10 h516909a_0 conda-forge xorg-libsm 1.2.3 h84519dc_1000 conda-forge xorg-libx11 1.6.9 h516909a_0 conda-forge xorg-libxau 1.0.9 h14c3975_0 conda-forge xorg-libxdmcp 1.1.3 h516909a_0 conda-forge xorg-libxt 1.2.0 h516909a_0 conda-forge xorg-xproto 7.0.31 h14c3975_1007 conda-forge xz 5.2.5 h516909a_0 conda-forge zeromq 4.3.2 he1b5a44_2 conda-forge zipp 3.1.0 py_0 conda-forge zlib 1.2.11 h516909a_1006 conda-forge zstd 1.4.4 h3b9ef0a_2 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : test active env location : /home/xylar/miniconda3/envs/test shell level : 2 user config file : /home/xylar/.condarc populated config files : /home/xylar/.condarc conda version : 4.8.3 conda-build version : 3.19.2 python version : 3.7.6.final.0 virtual packages : __glibc=2.27 base environment : /home/xylar/miniconda3 (writable) channel URLs : https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /home/xylar/miniconda3/pkgs /home/xylar/.conda/pkgs envs directories : /home/xylar/miniconda3/envs /home/xylar/.conda/envs platform : linux-64 user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.6 Linux/4.15.0-1079-oem ubuntu/18.04.4 glibc/2.27 UID:GID : 1001:1001 netrc file : None offline mode : False ```
CorbinFoucart commented 4 years ago

Perfect -- this worked well. I didn't know that it was inadvisable to mix and match conda defaults and conda-forge; thanks!