4

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?

Allanqunzi
  • 3,230
  • 1
  • 26
  • 58
  • Did you actually set PYTHONPATH to what you put in your question because if you did that's probably your problem – Andria Mar 20 '17 at 21:22

1 Answers1

3

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

Community
  • 1
  • 1
Allanqunzi
  • 3,230
  • 1
  • 26
  • 58