1

I'm working with the Python C API, and while I've googled and found somewhat cryptic answers (that don't solve my problem), I can't seem to get past this error.

When compiling my program with gcc -shared [...] 'pkg-config --cflags --libs python3' -fPIC [...] (And, yes, the pkg-config line is in backticks), but it produces this error message:

‘PyUnicodeUCS2_FromString((const char *)"[...]")’ is not a function

The line of offending code is simple: PyObject *value = PyUnicode_FromString("foo") which is practically taken from the Python3 documentation. The contents of the example compile fine and run in the Python interpreter without incident with the exact same command line arguments to gcc.

Any help is greatly appreciated! Thanks!

2
  • Missing ";" somewhere? Also, code says "foo" and the error says "[...]"? Commented Apr 6, 2012 at 4:09
  • It's just because I edited out the string contents because they're really long and I guess I changed them differently in the error and the code. Commented Apr 6, 2012 at 14:16

1 Answer 1

1

When embedding Python within an development environment (LabVIEW) I have encountered this. I was unable to find the PyUnicode_FromString function, from the Python documentation example, but I was able to use PyUnicodeUCS2_FromString, in the same way successfully.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.