I want to use python in c++ code, but it got an error, it is the simplest "hello word" program.
It is Ok to import PIL.Image, but for Tkinter, it will output "ImportError: No module named _tkinter". I had print the sys.path, but no clue.
Following snapshot show you the detail infomation: http://i.minus.com/iWoCUlidmq5M3.jpg
Env: Visual Studio 2010. Python 2.7.2, 32bit.
I am a new user, so I can't upload the picture. :(
This problem cost me several days, hope someone can give me some suggestions, very thanks.
here is another infomations:
source code :
int _tmain(int argc, _TCHAR* argv[])
{
Py_Initialize();
if(!Py_IsInitialized())
cout<< "init failed"<<endl;
PyRun_SimpleString ("import sys, struct, zlib ");
PyRun_SimpleString ("sys.path.append('C:\\Python27\\DLLs')");
PyRun_SimpleString ("sys.path.append('C:\\Python27\\libs')");
PyRun_SimpleString ("sys.path.append('C:\\Python27\\Lib\\lib-tk')");
PyRun_SimpleString ("sys.path.append('C:\\Python27\\Lib\\idlelib')");
PyRun_SimpleString ("sys.path.append('C:\\Python27\\lib\\plat-win')");
// PyRun_SimpleString ("print sys.path ");
PyRun_SimpleString ("import PIL.Image, StringIO");
PyRun_SimpleString ("import Tkinter");
}
error info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\Lib\lib-tk\Tkinter.py", line 38, in <module>
import FixTk
File "C:\Python27\Lib\lib-tk\FixTk.py", line 65, in <module>
import _tkinter
ImportError: No module named _tkinter