Problems installing gmsh

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Problems installing gmsh

Post by keithsloan52 »

I have installed the gmsh python module in the past but I am now having a problem getting FreeCAD to recognise a recent install.

From FreeCAD python console I am

Code: Select all

import sys
print(sys.path)
One of the directories listed is '/Applications/FreeCAD 0.19.1.app/Contents/Resources/lib/python3.8/site-packages'

My FreeCAD version is

Code: Select all

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.1)
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
And following instructions on https://pypi.org/project/gmsh/ but targeting the FreeCAD path run command

Code: Select all

pip install --upgrade gmsh -t '/Applications/FreeCAD 0.19.1.app/Contents/Resources/lib/python3.8/site-packages'
But if I try import gmsh from FreeCAD python console I get

Code: Select all

raceback (most recent call last):
  File "<input>", line 1, in <module>
ModuleNotFoundError: No module named 'gmsh'
If I list the contents of the site-packages I get

Code: Select all

gmsh-4.8.4-py3.8.egg-info
gmsh-4.8.4-py3.9.egg-info
but no plain gmsh subdirectory
User avatar
Roy_043
Veteran
Posts: 8577
Joined: Thu Dec 27, 2018 12:28 pm

Re: Problems installing gmsh

Post by Roy_043 »

Have you specified the path? F.e. in the Mesh_RemeshGmsh task panel.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Problems installing gmsh

Post by keithsloan52 »

Roy_043 wrote: Fri Jul 02, 2021 9:00 pm Have you specified the path? F.e. in the Mesh_RemeshGmsh task panel.
Not got that far, just trying import gmsh from FreeCAD python console. As far as I know if gmsh is installed to one of the directories
that show up with import sys; print(sys.path) it should work.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Problems installing gmsh

Post by keithsloan52 »

I notice that when I try and install gmsh I get a message about legacy setup

Code: Select all

pip install gmsh -t '/Applications/FreeCAD 0.19.1.app/Contents/Resources/lib/python3.8/site-packages' 
Collecting gmsh
  Using cached gmsh-4.8.4.tar.gz (10 kB)
Using legacy 'setup.py install' for gmsh, since package 'wheel' is not installed.
Installing collected packages: gmsh
    Running setup.py install for gmsh ... done
Successfully installed gmsh-4.8.4
But I still get this message after ensuring wheel is installed

Code: Select all

pip install wheel -t '/Applications/FreeCAD 0.19.1.app/Contents/Resources/lib/python3.8/site-packages' --upgrade
Collecting wheel
  Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.36.2
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Problems installing gmsh

Post by keithsloan52 »

Still have problems installing gmsh via pip

Asked in gmsh gitlab issues and got this reply
The way pip works is still quite mysterious to me. In case of trouble I would suggest simply downloading the binary SDK from gmsh.info, unpack it wherever you want, then simply add the "lib" subdirectory of the SDK to your PYTHONPATH variable. See https://gitlab.onelab.info/gmsh/gmsh/-/ ... README.txt
How would one adapt this for FreeCAD as I assume FreeCAD does not use PYTHONPATH?
Post Reply