Parsing expressions problem | "ImportError: Clang is not installed, cannot parse C code"

15 views
Skip to first unread message

Audrius-St

unread,
Apr 19, 2022, 3:20:34 PM4/19/22
to sympy
Hello,

I am attempting to parse C code into Python using SymPyExpression but am receiving the error message "ImportError: Clang is not installed, cannot parse C code"

However, I'm quite certain that I have Clang installed

$ conda list clang
# Name                Version         Build  Channel
clang                     13.0.1           ha770c72_0    conda-forge
clang-13               13.0.1           default_hc23dcda_0    conda-forge
libclang-cpp13     13.0.1          default_hc23dcda_0    conda-forge

Code fragment:

src_X = """
inline double advanceX(
    double const& x,
    double const& px,
    double const& y,
    double const& py,
    double const& t)
    // The C code output from FORM starts array indices at 1 not 0. Go figure.
    std::array<double, 33 + 1> w; 

    w[1]=1./3.*y;
    w[2]=139./33. + 19./2.*y;
    w[2]=w[2]*w[1];
    . . .
    double x_t=w[1] + x;
 
    return x_t;
"""

def main():
    p = SymPyExpression(src_X, 'c')
    p.convert_to_python()
    print('p:', p)


if __name__ == "__main__":
    main()

System:
Python 3.9.12
Sympy 1.10.1
VS Code 1.66.2
Ubuntu 20.04 on WSLg 1.0.33

Is there some parameter in VS Code that I need to set?
Puzzled.

Another unrelated issue. Just now, when I attempt to go to https://docs.sympy.org/
I receive the message 

404

There isn't a GitHub Pages site here.


Aaron Meurer

unread,
Apr 19, 2022, 3:23:38 PM4/19/22
to sy...@googlegroups.com
The error message should be improved there. You need clang-python.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/5a69ee30-2084-4f8c-929e-ddab57e254b0n%40googlegroups.com.
Message has been deleted

Audrius-St

unread,
Apr 19, 2022, 3:39:14 PM4/19/22
to sympy
Thanks for your prompt reply.

What is "clang-python" and from where may I download it?

A search on "clang-python" did return anything obvious.

Do you mean "python3-clang-13"?

I suggest that the documentation be updated with this required information.

Isuru Fernando

unread,
Apr 19, 2022, 3:48:13 PM4/19/22
to sy...@googlegroups.com
It should be python-clang.

Isuru

Audrius-St

unread,
Apr 19, 2022, 3:49:55 PM4/19/22
to sympy
Okay, I found "python-clang" on conda-forge and installed it.

$ conda list python-clang

# Name                    Version                   Build  Channel
python-clang              13.0.1          default_hccd1708_0    conda-forge

I now receive the error message:

NotImplementedError: Only bool, int and float are supported

My understanding of this error message is that arrays such as std::array<double, n> are not currently supported.
Is this correct?

Audrius-St

unread,
Apr 19, 2022, 3:52:57 PM4/19/22
to sympy
Or is "double" not currently not supported?
Reply all
Reply to author
Forward
0 new messages