I am trying to run the following code:
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <iostream>
int main()
{
Py_Initialize();
std::wcout << std::endl;
std::wstring pyPath = Py_GetPath();
std::wcout << L"Paths: " << pyPath << std::endl;
std::wcout << std::endl;
std::wstring pyPref = Py_GetExecPrefix();
std::wcout << L"Exec Prefix: " << pyPref << std::endl;
PyRun_SimpleString( "print('Hello World from Embedded Python!!!')" );
Py_Finalize();
return 0;
}
And get the following output in my console:
Could not find platform dependent libraries <exec_prefix>
Paths: C:\Program Files\Python311;C:\Program Files\Python311\python311_d.zip;C:\Program Files\Python311\Lib;C:\Program Files\Python311\DLLs
Exec Prefix: C:\Program Files\Python311
Hello World from Embedded Python!!!
The question is what should I do to eliminate the "Could not find platform dependent libraries <exec_prefix>" error? By eliminate I mean to make python to load its libraries correctly.
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.22)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(PROJ_NAME "Test")
project(${PROJ_NAME})
include_directories( $ENV{PYTHONPATH}/include )
link_directories( $ENV{PYTHONPATH}/libs )
list(APPEND SRC_LIST src/main.cpp)
add_executable(${PROJ_NAME} ${SRC_LIST})
And these are the values of the system variables:
PYTHONPATH - C:\Programm Files\Python311 PYTHONHOME - C:\Programm Files\Python311
The C:\Programm Files\Python311 path is also present in the PATH system variable
C:\Programm Files\Python311 is the folder where the python 3.11 is installed
When I run python from CMD, it does not show any errors:
>python --version
Python 3.11.0
>python
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit();