matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

Unable to run minimal example on Ubuntu

Open meganset opened this issue 6 years ago • 4 comments

My first try failed because a numpy .h file couldn't be located:

g++ minimal.cpp -std=c++11 -I ~/anaconda3/include/python3.7m -L ~/anaconda3/lib -lpython3.7m
In file included from minimal.cpp:1:0:
matplotlibcpp.h:17:12: fatal error: numpy/arrayobject.h: No such file or directory
 #  include <numpy/arrayobject.h>

If i added an additional include path for numpy, I was able to build

g++ minimal.cpp -std=c++11 -I ~/anaconda3/include/python3.7m -I ~/anaconda3/lib/python3.7/site-packages/numpy/core/include -L ~/anaconda3/lib -lpython3.7m

but running the file, i received:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

what am i doing wrong here..? thanks

meganset avatar Nov 22 '19 20:11 meganset

Hi, even I'm getting this error. Were you able to solve this? I'm running c++ on xeus-cling and we use matplotlib-cpp for displaying the images.

xlabd avatar Aug 12 '20 12:08 xlabd

If anyone gets this error, a solution for it is to force set PYTHONPATH and PYTHONHOME.

xlabd avatar Aug 18 '20 08:08 xlabd

If anyone gets this error, a solution for it is to force set PYTHONPATH and PYTHONHOME.

How to set it? in the bashrc file ?

OriLiMu avatar Oct 08 '20 14:10 OriLiMu

@woshichuanqilz Yes, you can do that. You can also use export to set the environment variables. I was creating a Docker image, so here is my solution. I have set the environment variables in the dockerfile itself.

xlabd avatar Oct 12 '20 07:10 xlabd