Thanks to visit codestin.com
Credit goes to github.com

Skip to content

std::runtime_error #124

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
PhilipDeegan opened this issue Jul 24, 2019 · 5 comments
Open

std::runtime_error #124

PhilipDeegan opened this issue Jul 24, 2019 · 5 comments

Comments

@PhilipDeegan
Copy link

PhilipDeegan commented Jul 24, 2019

g++ plot.cpp -Iext/plot/ $(python3-config --includes)  $(python3-config --ldflags) -o plot
LD_LIBRARY_PATH=/opt/py/python-3.7.3/lib ./plot
terminate called after throwing an instance of 'std::runtime_error'
  what():  Call to show() failed.
Aborted
which python3
/opt/py/python-3.7.3/bin/python3
echo $PYTHONHOME
/opt/py/python-3.7.3
@02yogesh16
Copy link

I am also facing the same issue; someone please provide the solution.

@PhilipDeegan
Copy link
Author

I used wrappy instead https://github.com/Dekken/wrappy/blob/plot/plot.cpp

@goksuguvendiren
Copy link

I am running into the same issue on an Ubuntu machine with python 2.7, and numpy disabled. Has anybody found a solution, rather than using another wrapper/library?

@mschmitz2
Copy link

I am running into the same issue (on Windows with Python 3.7 and numpy enabled).

Also, in case this is any help, if explicitly calling figure() before plotting (optional if only plotting to one figure), the std::runtime_error happens there: Call to figure() failed..

In all these cases, it seems like it is the call to

/* Call a callable Python object 'callable', with arguments given by the
   tuple 'args'.  If no arguments are needed, then 'args' can be NULL.

   Returns the result of the call on success, or NULL on failure.

   This is the equivalent of the Python expression:
   callable(*args). */
PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
                                           PyObject *args);

that fails by returning NULL.

@crbednarz
Copy link

I think this is the issue I'm encountering. Putting PyErr_Print(); after the failed call indicated that sys.argv wasn't set.

Adding the following after Py_Initialize(); fixed it for me:

        wchar_t* args[1];
        args[0] = Py_DecodeLocale("", NULL); 
        PySys_SetArgv(0, args);

bbalp added a commit to bbalp/matplotlib-cpp that referenced this issue Aug 15, 2020
bbalp added a commit to bbalp/matplotlib-cpp that referenced this issue Aug 15, 2020
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

5 participants