Open wknoben opened 7 months ago
Thanks for reporting this and for all the detail which is really helpful, @wknoben. On our small dev team we don't have much Mac OS experience (we are hardcore Linux users) which means we can't readily investigate this, but we do have access to a Mac in the office so we may be able to look into it in due course (though I am currently working fully remotely for the foreseeable so this is unlikely to be soon). (And unless I am mistake, one can't legally get a VM for Mac OS.)
I see from your report that you have followed the advice as quoted from the cfunits installation page, namely:
If the UDUNITS-2 shared library file (libudunits2.so.0 on GNU/Linux or libudunits2.0.dylibfile on MacOS) is in a non-standard location then its directory path should be added to the LD_LIBRARY_PATH environment variable. It may also be necessary to specify the location (directory path and file name) of the udunits2.xml file in the UDUNITS2_XML_PATH environment variable, although the default location is usually correct. For example, export UDUNITS2_XML_PATH=/home/user/anaconda3/share/udunits/udunits2.xml.
so there's not anything else I could suggest without the ability to play around on Mac OS myself,
As a workaround for installation, I would otherwise suggest you use conda
(or wrappers to it such as mamba
), but since you mention you are on an institutional machine, I guess this is not an option you can take? If not, then I'm afraid on our side there is not anything we can immediately offer to make it work (unless someone on my team else chips in with an idea).
I don't know if this is solvable on cfunits's side of things, but it seemed good to at least document this in case anyone else runs into this.
Indeed, regardless having this report up will be helpful to other Mac users, so thanks again for the write up. Please do let us know here if you find a way to get it working with Mac OS, or a workaround that can be applied without conda
.
I have this working on apple silicon ... but I can't remember what I did! Which isn't much help right now. ... I do have another Mac which I know doesn't have cf-python on it, so I'll have a go on that and see if I can a) recreate your problem, and b) work out what I must have done.
Meanwhile, is the issue that you can't even import cf
because of this error, or does it manifest under some particular circumstances?
@davidhassell I vaguely remember something about installing it from the GitHub version, can you recall what we did? I remember that I was stymied about something in the cf-python install, asked you to come in, and more or less instantly we got it going ... it was so instant that I never thought to document it :-(
@sadielbartholomew Thanks for chiming in. Installing through conda
prevents this issue for me. Unfortunately it doesn't solve my entire problem because I can't get the package I'm actually after (which has cfunits
as a requirement) installed with conda for a different reason. The specific problem documented here can be avoided this way though.
Solution code for those looking for it:
conda create -n cfunits_test
conda activate cfunits_test
conda install -c conda-forge cfunits
@bnlawrence Thanks for taking a look. This prevents me from importing the package at all. import cfunits
immediately reports the error in the top post.
@wknoben The memory archaeology I've done so far suggests that I probably ended up using mamba and the problem went away ... can you not install cfunits
with conda, then pip install the package you want into that environment?
Possibly, I haven't tried that yet. In my experience that can get messy but it may be worth it if it's the only way to make things work.
I'm having some trouble getting cfunits to work on my M2 Macbook Pro. Installing
cfunits
3.3.6 reports no errors, but trying to import the package returns a library not found error:udunits
is present on the system:I (sequentially) tried setting paths and reinstalling
cfunits
to no avail:and
Further digging brings up to this related issue: https://github.com/orgs/Homebrew/discussions/3424.
Summary:
ctypes.util.find_library()
will look in/usr/lib
and/usr/local/lib
to findudunits2
but on newer Apple hardware libraries will be installed in/opt/homebrew
insteadhttps://github.com/NCAS-CMS/cfunits/blob/fac74a58f51f9f68173fa96e75f8c1d8ae75e524/cfunits/units.py#L39
The linked thread suggest setting a symlink will solve this, but on institutional machines (like mine), I wasn't able to make this work.
I don't know if this is solvable on
cfunits
's side of things, but it seemed good to at least document this in case anyone else runs into this.