conda-forge install gives RuntimeError on "from fenics import *"

132 views
Skip to first unread message

Tom Pace

unread,
Sep 12, 2017, 10:00:49 AM9/12/17
to fenics-...@googlegroups.com
Hello and thank you for all your work on FEniCS. I tried to install it through anaconda using "conda install -c conda-forge fenics". The installation seemed to succeed, installing version 2017.1.0-py36_5.

However, when I started python and issued "from fenics import *" I got "RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa".
Furthermore, I got another exception during handling of the one above: "ModuleNotFoundError: No module named '_common'".

I have numpy version 1.12.1, which is what was there before the FEniCS installation, although the numpy package itself was replaced with one from conda forge during the FEniCS installation.

Also, I can do 'import numpy.core.multiarray' at the python prompt without an error. That module's __version__ is 3.1.

If I understand correctly (which I may not), the numpy API version 0xb corresponds to numpy version 1.13 or above. Reference:
https://github.com/numpy/numpy/blob/master/numpy/core/code_generators/cversions.txt

I've copied the complete traceback below. I'm using ubuntu 16.04 LTS and conda 4.3.23 in case that helps.

Thanks again,
Tom Pace

-----------------
>>> from fenics import *
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/dolfin/cpp/common.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "/u1/tgpa222/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: numpy.core.multiarray failed to import

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/fenics/__init__.py", line 7, in <module>
    from dolfin import *
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/dolfin/__init__.py", line 17, in <module>
    from . import cpp
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/dolfin/cpp/__init__.py", line 43, in <module>
    exec("from . import %s" % module_name)
  File "<string>", line 1, in <module>
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/dolfin/cpp/common.py", line 21, in <module>
    _common = swig_import_helper()
  File "/u1/tgpa222/anaconda3/lib/python3.6/site-packages/dolfin/cpp/common.py", line 20, in swig_import_helper
    return importlib.import_module('_common')
  File "/u1/tgpa222/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_common'

Garth N. Wells

unread,
Sep 12, 2017, 10:02:44 AM9/12/17
to Min Ragan-Kelley, fenics-support, Tom Pace
Min,

This error with NumPy comes up frequently. Do you know what the best fix is?

Garth
> --
> You received this message because you are subscribed to the Google Groups
> "fenics-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fenics-suppor...@googlegroups.com.
> To post to this group, send email to fenics-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/fenics-support/CABhDOROnh%2Bi9oDKmet8ypFVY3Vw49jUyDX1pZDNgFV8jsrTRyA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Tom Pace

unread,
Sep 14, 2017, 10:36:05 AM9/14/17
to Garth N. Wells, Min Ragan-Kelley, fenics-support
I checked to see if a newer version of numpy was available from conda forge with 'conda update -c conda-forge numpy'. Sure enough, that installed numpy 1.13.1, which has the higher API version. 'from fenics import *' now works.

I just wish I knew what caused conda to install incompatible package versions in the first place.

Thanks,
Tom

> email to fenics-support+unsubscribe@googlegroups.com.
> To post to this group, send email to fenics-support@googlegroups.com.

MinRK

unread,
Sep 15, 2017, 10:41:40 AM9/15/17
to Tom Pace, fenics-support
We should have been pinning the numpy version in the conda package, but weren't, which allowed an incompatible version to be installed.

https://github.com/conda-forge/fenics-feedstock/pull/53 should pin the numpy dependency, which ought to stop this happening.

-Min

--
Reply all
Reply to author
Forward
0 new messages