Allanqunzi Allanqunzi -4 years ago 155
Python Question

"No module named site" when embedding python in c++ in Visual studio

there are similar questions on StackOverflow, but I couldnt find any helpful.
I am embedding python in c++ in visual studio. My python is in anaconda, and the directory for anaconda is c:/anaconda2, my code is very simple

#include <Python.h>
int main()
{
Py_initialize();
}


I am so surprised even this simple code generates the error


ImportError: No module named site


And I have set
PYTHONHOME=c:\Anaconda2\python27
,
PYTHONPATH=c"\Anaconda2\libs
, and appended
PYTHONHOME
and
PYTHONPATH
to system variable
path
. I also put
C:\Anaconda2\libs\python27
into
Library Directories
in the property sheets. But I still getting this
ImportError
, can anyone please help?

Answer Source

site.py is in C:\Anaconda2\Lib, after appending PYTHONPATH with C:\Anaconda2\Lib, problem solved. Also see this question

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download