Skip to content

PyError: 'pkg-config is not installed' #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aterenin opened this issue Aug 14, 2018 · 9 comments
Open

PyError: 'pkg-config is not installed' #52

aterenin opened this issue Aug 14, 2018 · 9 comments

Comments

@aterenin
Copy link

Fresh installation of Julia 1.0.

ERROR: PyError (PyImport_ImportModule) <class 'OSError'>
OSError('pkg-config is not installed',)
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/fenics/__init__.py", line 7, in <module>
    from dolfin import *
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/__init__.py", line 140, in <module>
    from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/fem/assembling.py", line 34, in <module>
    from dolfin.fem.form import Form
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/fem/form.py", line 12, in <module>
    from dolfin.jit.jit import dolfin_pc, ffc_jit
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/jit/jit.py", line 15, in <module>
    if pkgconfig.exists("dolfin"):
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/pkgconfig/pkgconfig.py", line 62, in _wrapper
    raise EnvironmentError("pkg-config is not installed")

What can I do to debug this?

@ysimillides
Copy link
Contributor

I've not updated the package to work for 1.0 but will hopefully do this by the weekend. If I'm not mistaken though, this seems to be a Conda Issue.

@aterenin
Copy link
Author

I see. I'll downgrade to 0.7.

@aterenin
Copy link
Author

Confirmed same issue on 0.7.

@aterenin
Copy link
Author

Confirmed same issue on 0.6.2. I'd like to at minimum get a working FEniCS installation again - if this is a Conda issue, can I do anything to debug it?

@clason
Copy link

clason commented Aug 20, 2018

Julia 1.0, FEniCS.jl master, miniconda 4.5.10 and FEniCS 2018.1 works for me (linux x86_64). Are you sure you have set conda activate fenicsproject? If I forget that, I get exactly the error you report.

@clason
Copy link

clason commented Aug 22, 2018

Aha, found the culprit! Whenever PyCall rebuilds (e.g., after an update), it resets to the default python, which is the system python unless you have activated a conda environment. So whenever PyCall updates, you need to explicitly reset to the Conda environment by doing

ENV["PYTHON"]=""
using Pkg; Pkg.build("PyCall")

and then restart julia.

@clason
Copy link

clason commented Aug 22, 2018

@aterenin Have you installed mshr by any chance? I can reproduce the problem if I install mshr. Curiously, it will say

The following packages will be UPDATED:

    fenics: 2016.1.0-py35_1                     conda-forge --> 2018.1.0-py35he4728cc_0               conda-forge

The following packages will be DOWNGRADED:

    numpy:  1.15.1-py35_blas_openblashd3ea46f_0 conda-forge [blas_openblas] --> 1.14.5-py35_blas_openblashd3ea46f_201 conda-forge [blas_openblas]

(even though both Conda.list() shows the correct fenics version before that, looking at fenics.DOLFIN_VERSION_STRING shows that it was actually installing 2016.1.0). So something is definitely screwy with Conda.jl, at least on macOS. You might want to open an issue; in the meantime, I recommend installing FEniCS via an external miniconda installation and accessing this. (Make sure to install sympy=1.1.1 because the default sympy 1.2 is not compatible yet. Also, don't forget to Pkg.build(PyCall) with the correct environment activated!)

@aterenin
Copy link
Author

aterenin commented Aug 22, 2018 via email

@clason
Copy link

clason commented Aug 22, 2018

@aterenin Since FEniCS.jl just wraps the PyCall (and, apparently installs FEniCS via Conda.jl), it will run into the same issues. Here's what (sort of) works (the order of the steps matter!):

  1. cd .julia/packages ; rm -rf Conda
  2. open julia, type
]add Conda
using Conda
Conda.add("sympy=1.1") # and matplotlib and scipy, if desired
  1. restart julia (for safe measure)
ENV["PYTHON"]=""
using Pkg; Pkg.build("PyCall")
  1. restart julia (necessary)
using PyCall
@pyimport fenics as fe   # :smile:
fe.DOLFIN_VERSION_STRING # :sadface:
  1. ]add FEniCS if desired.

The only possible conclusion is that FEniCS from Conda.jl has to be assumed to be broken at the moment on macOS. On the other hand, direct install via miniconda does work, so that would be my recommended workaround (and actually standard way):

  1. Download and install miniconda from https://docs.conda.io/en/latest/miniconda.html via terminal (sh Miniconda...; I like to install to /usr/share/local/conda).
  2. Set up the paths as the installer tells you (assuming you use bash). If it tells you to conda update -n base conda, do so. (The package environment is somewhat fragile, so updating after the packages are installed may break things!)
  3. From the terminal, do
conda create -n fenics -c conda-forge fenics sympy=1.1 matplotlib scipy mshr

Grab a cup of tea.

  1. When it's finished, do conda activate fenics.
  2. Check that everything works correctly: start python3
import dolfin as fe
fe.__version__
  1. start julia
ENV["PYTHON"]="python3"
using Pkg; Pkg.build("PyCall")
  1. restart julia, check that everything works correctly:
using PyCall
@pyimport dolfin as fe
fe.__version__
mesh = fe.UnitSquareMesh(64,64)
V = fe.FunctionSpace(mesh,"CG",1) # should trigger FFC compilation
  1. (optional) ]add FEniCS.

Again, whenever PyCall.jl gets updated, make sure you repeat step 6 with conda activate fenics.

If this works for you, maybe @ysimillides or @ChrisRackauckas can put these instructions (which also work for linux) in the README or the Wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants