2011-12-12 5 views
1

Python을 C++ 코드로 사용하고 싶지만 오류가 발생했습니다. 가장 간단한 "hello word"프로그램입니다.ImportError : _tkinter라는 모듈이 없습니다.

PIL.Image를 가져 오는 것이 좋습니다. 그러나 Tkinter의 경우 "ImportError : No module named _tkinter"를 출력합니다. sys.path를 인쇄했지만 실마리가 없습니다.

다음 스냅 샷 쇼 당신에게 세부 정보] : http://i.minus.com/iWoCUlidmq5M3.jpg

봉투 : Visual Studio 2010에서 Visual Studio 2010을 파이썬 2.7.2, 32 비트를.

나는 새로운 사용자이므로 사진을 업로드 할 수 없습니다. .

소스 코드 :

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"); 
} 

오류 정보 :(

이 문제는 며칠 나 비용 누군가가 나에게 매우 감사합니다 몇 가지 제안을 줄 수 있기를 바랍니다 여기

다른 infomations입니다 :

답변

0

디버그 python_d.dll을 사용했기 때문에이 문제가 해결되었으므로 디버그 버전의 pyd 파일을 찾을 수 없으므로 실패했습니다.

그러면 python.dll을 python_d.dll로 변경하고 pyconfig에서 디버그 프로 세서를 삭제합니다.

0

EXE가 DLL (또는 PYD hat은 C : \ Python27 \ DLLs에 있습니다). 이 폴더를 Windows 경로에 추가해야합니다. https://stackoverflow.com/a/428217/117092

+0

안녕하세요, 귀하의 회신을 보내 주셔서 감사합니다, 나는 _tkinter.pyd Windows의 시스템 경로에 배치 된 경로 "C : \ Python27 \ DLLs"을 추가했지만 노력하지 않았습니다. – yhl10000