embed Python in c++, how to unset 'PYTHONHOME'

Viewed 26

I'm trying to embed python in my c++ using visual studio code. Just a simple Initialize for now:

#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <Python.h>


int main() {
  Py_Initialize();  
  Py_Finalize();
  return 0;
}

When I run I get this:

Python path configuration:
  PYTHONHOME = 'C:\MinGW64\bin\..\opt'
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'c:\\Users\\**USERNAME**\\Desktop\\C++ testing\\new.exe'
  sys.base_prefix = 'C:\\MinGW64\\bin\\..\\opt'
  sys.base_exec_prefix = 'C:\\MinGW64\\bin\\..\\opt'
  sys.platlibdir = 'lib'
  sys.executable = 'c:\\Users\\**USERNAME**\\Desktop\\C++ testing\\new.exe'
  sys.prefix = 'C:\\MinGW64\\bin\\..\\opt'
  sys.exec_prefix = 'C:\\MinGW64\\bin\\..\\opt'
  sys.path = [
    'C:\\Users\\**USERNAME**\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
    'C:\\MinGW64\\bin\\..\\opt\\DLLs',
    'C:\\MinGW64\\bin\\..\\opt\\lib',
    'c:\\Users\\**USERNAME**\\Desktop\\C++ testing',
  ]
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 0x00001f54 (most recent call first):
  <no Python frame>

It looks like "PYTHONHOME" is set to an incorrect directory. How would I change it?

0 Answers
Related