lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.28k stars 1.12k forks source link

problems running matplotlibcpp #266

Open jbensabat opened 3 years ago

jbensabat commented 3 years ago

Hello I have installed matplotlibcpp with the CMAKE GUI I have previously installed the python libs through anaconda (miniconda3)

  1. In this installation there are no debug libs 2.I tried the release version which builds an executable but then I get the following error msg

Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'plotting' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = 'C:\matplotlibcpp\build\bin\Release\bar.exe' sys.base_prefix = 'C:\Miniconda3' sys.base_exec_prefix = 'C:\Miniconda3' sys.platlibdir = 'lib' sys.executable = 'C:\matplotlibcpp\build\bin\Release\bar.exe' sys.prefix = 'C:\Miniconda3' sys.exec_prefix = 'C:\Miniconda3' sys.path = [ 'C:\Miniconda3\python39.zip', '.\DLLs', '.\lib', 'C:\matplotlibcpp\build\bin\Release', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings'

Current thread 0x000015dc (most recent call first):

Is there any guidance on how to properly set python and its dependencies ? thanks jac
Basilisvirus commented 3 years ago

I get the same error but with ModuleNotFoundError: No module named 'matplotlib' Any fixes yet?

DentonW commented 2 years ago

I ran into both of these, because my Anaconda environment was not activated: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment. If you use their solution of running the activation script in the Command Prompt, it sets the proper environment variables, but those are not persistent. You can take note of what environment variables it sets and set yourself manually, or you can reinstall Anaconda with the option of setting the environment variables. Anaconda does not recommend doing that, but I haven't seen an issue so far.

duxinpeng commented 1 year ago

I ran into the same problem as you I added this code at the beginning of the main function to set the environment variables Py_SetPythonHome(L"C:/Users/UesrName/anaconda3/envs/EnvName"); and it will run correctly. This path is the location of your python interpreter.