PIP installers available!

Dear NGSolve users,

Finally we managed to provide pip-installers for our software. This means, installing NGSolve on your computer now becomes as easy as py!
pip install ngsolve

For Linux, we also provide an ngsolve-avx2 package which is compiled using AVX2 instructions (only working on supported hardware).

Also nightly builds will be provided (use the --pre flag of pip to install prerelease versions).

Similar to the conda installers, run-time code generation is currently not supported on all platforms, but we are working on it.

Best,
The NGSolve Team

test

Some people reported problems starting Python after installing the ngsolve pip-package on MacOS, and after rebooting. Updating ngsolve to the NGSolve-6.2.2202 release solves the problem.
If pip is also not working (because of this problem), you can manually delete the directory /Library/Frameworks/Python.framework/Versions/3.10/Contents ( change 3.10 to your python version).

The error message you get, when having this problem looks like this:
dyld[3600]: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.10/Python
Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
Reason: tried: ‘/Library/Frameworks/Python.framework/Versions/3.10/Python’ (code signature invalid (errno=1) sliceOffset=0x004B0000, codeBlobOffset=0x00483BA0, codeBlobSize=0x000135F0 for

Best,
Matthias

I am having issues with installing it through pip on Ubuntu 21.10. It does not seem to install with umfpack, something that the apt version did.

Running the following line a_assembled.mat.Inverse(freedofs=freedofs, inverse="umfpack") works with the apt version, but crashes the pip installation.

Is this an oversight, a temporary limitation, or a permanent limitation of the pip install?

Additionally, this page shows the default CMake options when building from source. Is there a list to show which options are enabled for the different distribution modes (pip, apt, conda, etc.) of NGSolve?

Any update on this?

Hi everyone!
I tried the pip installer on windows with anaconda

Running the conda environement
conda create -n test python=3.9
I gave pip install ngsolve a try. The install works, even netgen opens a gui, but ngsolve cannot find ngslib.
(EDIT: I tried without conda and got the same result.)

from .ngslib import version, ngstd, bla, la, fem, comp, solve
ImportError: DLL load failed while importing ngslib: The specified module could not be found.

I tried to add everything to PATH and PYTHONPATH by hand without success. I uploaded the output of conda info --system here

I also tried
conda install -c ngsolve ngsolve
but could not find a python version that would satisfy the specifications. I tried python3.9 giving

  • ngsolve → python[version=‘>=3.7,<3.8.0a0|>=3.8,<3.9.0a0’]
    so I tried python3.7 telling me
  • ngsolve → python[version=‘>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.10,<3.11.0a0|>=3.9,<3.10.0a0’]

Any hints to get this working?

Cheers,
Paul

Dear Developers,
I am facing the very same problems described by paul.stocker.
Which version of Anaconda should we use?
Is there a workaround to solve the problem?
Thanks a lot and best regards,
Mauro Sgroi.

Hello Sgroi,

I could reproduce the problem on Windows. One possible workaround is to do the following:

import netgen,os
netgen_dir = os.path.dirname(netgen.__file__))
os.add_dll_directory(netgen_dir)
os.path["PATH"] += os.pathsep + netgen_dir
import ngsolve

I just added these lines to the ngsolve sources, a new nightly pip build will be released later today.
Note that the conda channel ngsolve is not maintained, pip is the preferred way to install ngsolve.

Best,
Matthias

Hi Sgroi & Matthias,
thank you for your reply!
For me, the import of netgen already fails, so this does not solve it in my case. My error is:

import netgen
File “C:\Users\IEUser\AppData\Local\Programs\Python\Python310\lib\site-packages\netgen_init_.py”, line 18, in
from . import libngpy
ImportError: DLL load failed while importing libngpy: The specified module could not be found.

I put the site_package dir and even the netgen and ngsolve dir into my PATH and PYTHONPATH, is there any other variable I should be aware of so python can find the files?

Weirdly enough, the init of netgen can import the config file but fails on the libngpy.
I then tried to import libngpy from inside the config file and it worked… wat? (But still failing to import libngs later on…)

Bests,
Paul

Dear Matthias,
I tried your solution but I get the following error:

os.path[“PATH”] += os.pathsep + netgen_dir
TypeError: ‘module’ object is not subscriptable

How should I proceed?
Thanks a lot and best regards,
Mauro Sgroi.

Oh, I had a typo there, the line should be

os.environ[“PATH”] += os.pathsep + netgen_dir

Best,
Matthias

Dear Matthias,
now I can import properly ngsolve.
I still have an issue with the first problem of the tutorial, the Poisson example. I modified the Jupyter notebook as follows:
import netgen,os
netgen_dir = os.path.dirname(netgen.file)
os.add_dll_directory(netgen_dir)
os.environ[“PATH”] += os.pathsep + netgen_dir
from ngsolve import *
#from netgen.geom2d import unit_square
from netgen.occ import unit_square
from ngsolve.webgui import Draw

but executing Draw (gfu, mesh) I get the following error:

TypeError Traceback (most recent call last)
Cell In [7], line 1 ----> 1 Draw (gfu, mesh)

TypeError: Draw(): incompatible function arguments. The following argument types are supported:

  1. (cf: ngsolve.fem.CoefficientFunction, mesh: ngsolve.comp.Mesh, name: str, sd: int = 2, autoscale: bool = True, min: float = 0.0, max: float = 1.0, draw_vol: bool = True, draw_surf: bool = True, reset: bool = False, **kwargs) → None
  2. (gf: ngsolve.comp.GridFunction, sd: int = 2, autoscale: bool = True, min: float = 0.0, max: float = 1.0, **kwargs) → None
  3. (mesh: ngsolve.comp.Mesh, **kwargs) → None
  4. (arg0: object) → None

Invoked with: <ngsolve.comp.GridFunction object at 0x000001ECA9D6D860>, <ngsolve.comp.Mesh object at 0x000001ECA9C3CDB0>
So essentially I cannot plot the solution.
Thanks a lot in advance and best regards,
Mauro.

Hi Mauro,
you have to pass a string as name for the function in the third argument. Something like
Draw (gfu, mesh, “gfu”)
should work.
Also, in case you want the drawing to show up in the notebook (and not in the netgen gui) you need to install the webgui, you can find the instructions here:
https://docu.ngsolve.org/latest/i-tutorials/index.html

Can you tell me which python version and ngsolve version you are using? I still cannot import netgen.
Cheers, Paul

Dear Paul,
Thanks for the suggestion.
It fixed the error but the graph is not showing. I followed the installation instruction about Jupyter extensions, Maybe I am missing something.

My conda version is: 22.9.0
python 3.9.13
NGSolve-6.2.2204

I installed ngsolve via pip but I had to remove tbb from conda using conda remove.

Best regards,
Mauro.

When I tried using the pip installer on my machine it installed mkl-2023.0.0, which appears to be incompatible with the rest of ngsolve.

Downgrading mkl to version 2021.4.0 fixed the issue.

Hi all,

I am attempting to install ngsolve version 6.2.2204 (for compatibility reasons with xfem) and when I do “pip3 install ngsolve==6.2.2204” I receive the following error message:ERROR: Could not find a version that satisfies the requirement ngsolve==6.2.2204 (from versions: 6.2.2204.post148.dev0, 6.2.2204.post160.dev0, 6.2.2204.post192.dev0, 6.2.2301, 6.2.2301.post259.dev0, 6.2.2302)ERROR: No matching distribution found for ngsolve==6.2.2204

Is there something going on on my end? I appreciate any help!

Best,
Diana

Hi Diana,

what OS are you on and what python version are you using? Thy pypi installers of ngsolve 6.2.2204 are only available for python 3.8, 3.9 and 3.10.

Best wishes,
Henry

Hey,

Please wait a few days. We are also working on a new release for ngsxfem which should solve the compatibility issues as well.

Best,
Christoph

Hey Diana,

We release a new version of ngsxfem at the end of last week. Please give it another go!

Best,
Christoph

where can I find this PIP installer for MacOS Monterey version? I have this problem showing up when I launch Netgen. Here is what I get when I open Netgen below. what do I do to be able to open Netgen? I tried downloading Python and it didnt work. thanks /Applications/Netgen.app/Contents/MacOS/startup.sh ; exit; farahpiatek@Farahs-MacBook-Air ~ % /Applications/Netgen.app/Contents/MacOS/startup.sh ; exit;dyld[13301]: Library not loaded: ‘/Library/Frameworks/Python.framework/Versions/3.8/Python’ Referenced from: ‘/Applications/Netgen.app/Contents/MacOS/netgen’ Reason: tried: ‘/Library/Frameworks/Python.framework/Versions/3.8/Python’ (no such file), ‘/System/Library/Frameworks/Python.framework/Versions/3.8/Python’ (no such file)/Applications/Netgen.app/Contents/MacOS/startup.sh: line 10: 13301 Abort trap: 6 $Netgen_MACOS/netgen Saving session…copying shared history…saving history…truncating history files…completed.Deleting expired sessions…none found. [Process completed]

Hi!

You were using the .dmg bundle, right? This depends on a specific Python Version (3.8). So you could install Python3.8 to solve the problem.

But I advise you to use the pip installer instead, remove the bundle and then run:
python3 -m pip install ngsolve

Best,
Matthias