conda-forge / gmsh-feedstock

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

gmsh.dll not found when importing gmsh (with both gmsh and python-gmsh installed) #62

Closed bva99 closed 2 years ago

bva99 commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

When importing gmsh in a python code, I get a FileNotFoundError, saying that 'C:\Users\admin\anaconda3\envs\gmshEnv\Library\bin\gmsh.dll' (or one of its dependencies) could not be found, where "gmshEnv" is the name of my minimum example environment.

Using Windows 10 x64. conda is uptodate. Using Python 3.9.

When opening C:\Users\admin\anaconda3\envs\gmshEnv\Library\bin, gmsh.dll can be found there.

I have configured the default anaconda, conda-forge and intel channels as sources.

Simple steps for reproducing the issue:

(base) C:\Users\admin>conda create --name gmshEnv python=3.9 nomkl gmsh python-gmsh -y
...
(base) C:\Users\admin>conda activate gmshEnv
(gmshEnv) C:\Users\admin>python
Python 3.9.12 ... :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmsh
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\admin\anaconda3\envs\gmshEnv\lib\site-packages\gmsh.py", line 53, in <module>
    lib = CDLL(libpath)
  File "C:\Users\admin\anaconda3\envs\gmshEnv\lib\ctypes\__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\users\admin\anaconda3\envs\gmshEnv\Library\bin\gmsh.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Installed packages

# packages in environment at C:\Users\admin\anaconda3\envs\gmshEnv:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8            vc14h53ad9d4_9  [vc14]  intel
ca-certificates           2022.4.26            haa95532_0
certifi                   2022.5.18.1      py39haa95532_0
colorama                  0.4.4              pyhd3eb1b0_0
curl                      7.82.0               h2bbff1b_0
double-conversion         3.1.5                ha925a31_1
eigen                     3.3.7                h59b6b97_1
expat                     2.4.8                h39d44d4_0    conda-forge
ffmpeg                    4.3.1                ha925a31_0    conda-forge
fltk                      1.3.8                hb0cff51_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hd3eb1b0_0
font-ttf-inconsolata      2.001                hcb22688_0
font-ttf-source-code-pro  2.030                hd3eb1b0_0
font-ttf-ubuntu           0.83                 h8b1ccd4_0
fontconfig                2.14.0               hce3cb01_0    conda-forge
fonts-anaconda            1                    h8fa9717_0
fonts-conda-ecosystem     1                    hd3eb1b0_0
freeimage                 3.18.0               h6676e37_8    conda-forge
freetype                  2.10.4               hd328e21_0
gl2ps                     1.4.2                hce2df77_1
glew                      2.1.0                hd77b12b_3
gmsh                      4.10.3               hec9a65b_0    conda-forge
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.6               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       68.1                 h6c2663c_0
imath                     3.1.5                h12d4b20_0    conda-forge
intelpython               2022.1.0                      0    intel
jbig                      2.1               h8d14728_2003    conda-forge
jpeg                      9e                   h2bbff1b_0
jsoncpp                   1.9.4                h59b6b97_2
jxrlib                    1.1                  he774522_2
lcms2                     2.12                 h83e58a3_0
lerc                      3.0                  hd77b12b_0
libblas                   3.9.0           5_hd5c7e75_netlib    conda-forge
libcblas                  3.9.0           5_hd5c7e75_netlib    conda-forge
libclang                  11.1.0          default_h5c34c98_1    conda-forge
libcurl                   7.82.0               h86230a5_0
libdeflate                1.8                  h2bbff1b_5
libiconv                  1.16                 h2bbff1b_2
liblapack                 3.9.0           5_hd5c7e75_netlib    conda-forge
libnetcdf                 4.8.1                h6685c40_1
libogg                    1.3.5                h2bbff1b_1
libpng                    1.6.37           vc14h53ad9d4_8  [vc14]  intel
libraw                    0.20.2               hee1bdec_1    conda-forge
libssh2                   1.10.0               hcd4344a_0
libtheora                 1.1.1                h8cc25b3_3
libtiff                   4.3.0                hd413186_2    conda-forge
libwebp-base              1.2.2                h2bbff1b_0
libxcb                    1.13              hcd874cb_1004    conda-forge
libxml2                   2.9.14               h0ad7f3c_0
libzip                    1.8.0                h49b8836_0
libzlib                   1.2.12               h8ffe710_0    conda-forge
loguru                    0.5.3            py39haa95532_3
lz4-c                     1.9.3                h2bbff1b_1
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
msys2-conda-epoch         20160418                      1
nomkl                     1.0                  h5ca1d4c_0    conda-forge
numpy                     1.22.4           py39h0948cea_0    conda-forge
occt                      7.6.2                h8294837_3    conda-forge
openexr                   3.1.5                hab3b255_0    conda-forge
openjpeg                  2.4.0                h4fc8c34_0
openssl                   1.1.1o               h2bbff1b_0
pip                       21.2.4           py39haa95532_0
proj                      8.2.0                h1cfcee9_0    conda-forge
pthread-stubs             0.3                  h3c9f919_1
pugixml                   1.11.4               hd77b12b_1
python                    3.9.12               h6244533_0
python-gmsh               4.10.3               h57928b3_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
qt                        5.12.9               h5909a2a_4    conda-forge
rapidjson                 1.1.0                he980bc4_0
setuptools                61.2.0           py39haa95532_0
sqlite                    3.38.3               h2bbff1b_0
tbb                       2020.3           vc14_intel_311  [vc14]  intel
tbb-devel                 2020.3           vc14_intel_311  [vc14]  intel
tzdata                    2022a                hda174b7_0
utfcpp                    3.2.1                haa95532_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
vtk                       9.1.0           no_osmesa_py39h7ab63fb_100    conda-forge
wheel                     0.37.1             pyhd3eb1b0_0
win32_setctime            1.1.0              pyhd3eb1b0_0
wincertstore              0.2              py39haa95532_2
xorg-fixesproto           5.0               hcd874cb_1002    conda-forge
xorg-kbproto              1.0.7             hcd874cb_1002    conda-forge
xorg-libice               1.0.10               hcd874cb_0    conda-forge
xorg-libsm                1.2.3             hcd874cb_1000    conda-forge
xorg-libx11               1.7.2                hcd874cb_0    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xorg-libxext              1.3.4                hcd874cb_1    conda-forge
xorg-libxfixes            5.0.3             hcd874cb_1004    conda-forge
xorg-libxrender           0.9.10            hcd874cb_1003    conda-forge
xorg-renderproto          0.11.1            hcd874cb_1002    conda-forge
xorg-xextproto            7.3.0             hcd874cb_1002    conda-forge
xorg-xproto               7.0.31            hcd874cb_1007    conda-forge
xz                        5.2.5                h8cc25b3_1
zlib                      1.2.12               h8ffe710_0    conda-forge
zstd                      1.5.2                h19a0ad4_0

Environment info

active environment : gmshEnv
    active env location : C:\Users\admin\anaconda3\envs\gmshEnv
            shell level : 2
       user config file : C:\Users\admin\.condarc
 populated config files : C:\Users\admin\.condarc
          conda version : 4.13.0
    conda-build version : 3.21.8
         python version : 3.8.12.final.0
       virtual packages : __cuda=11.6=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\admin\anaconda3  (writable)
      conda av data dir : C:\Users\admin\anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/intel/win-64
                          https://conda.anaconda.org/intel/noarch
          package cache : C:\Users\admin\anaconda3\pkgs
                          C:\Users\admin\.conda\pkgs
                          C:\Users\admin\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\admin\anaconda3\envs
                          C:\Users\admin\.conda\envs
                          C:\Users\admin\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.8.12 Windows/10 Windows/10.0.19043
          administrator : False
             netrc file : None
           offline mode : False
isuruf commented 2 years ago

Can you try creating a new environment with just conda-forge channel? We don't support mixing defaults and conda-forge channel.

bva99 commented 2 years ago

Not sure if relevant, but I had to conda clean --all before doing the following:

Create a yaml file called gmshEnv.yml for a minimum working conda environment with "nodefaults" option:

name: gmshEnv
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python=3.9
  - nomkl
  - gmsh
  - python-gmsh

Installed the environment with conda create env -f gmshEnv.yml and activated it. gmsh now works!

(gmshEnv) C:\Users\admin>python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmsh
>>> gmsh.initialize()
>>> gmsh.fltk.run()  # close window to continue
>>> gmsh.finalize()
>>> quit()
(gmshEnv) C:\Users\admin>

No errors

I guess there were conflicts with the default packages? In any case, I believe I should start making a yaml file per environment.

Thank you @isuruf !