| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4553 人关注过本帖
标题:windows下Python调用Python出现error LNK2019
只看楼主 加入收藏
小鑫小
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-3-15
收藏
 问题点数:0 回复次数:0 
windows下Python调用Python出现error LNK2019
无法解析的外部符号 _PyCallable_Check,该符号在函数 _main 中被引用    等一些有关Python的函数都无法解析;
一下是我写的代码
#include<iostream>
#include<Python.h>
#include <codecvt>
using namespace std;
int main()
{
    Py_Initialize();
    if (!Py_IsInitialized())
    {
        return -1;
    }
    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.patth.append('.\')");

    PyObject *pName, *pModule, *pDict, *pFunc;
    wstring str = L"statistic_word";
    wstring_convert<codecvt_utf8<wchar_t>> conv;
    string sr = conv.to_bytes(str);

    pName = PyUnicode_FromUnicode(str.c_str(),str.size());
    pModule = PyImport_ImportModule(sr.c_str());

    if (!pModule)
    {
        cout << "can't find statistic_word.py" << endl;
        return -1;
    }

    pDict = PyModule_GetDict(pModule);
    if (pDict)
    {
        return -1;
        
    }
    pFunc = PyDict_GetItemString(pDict,"cut_word");
    if (!pFunc || !PyCallable_Check(pFunc))
    {
        cout << "can;t find function [cut_word]" << endl;
        return -1;
    }
    PyEval_CallObject(pFunc,NULL);
    Py_Finalize();
    system("pause");
    return 0;
}
搜索更多相关主题的帖子: windows include return import 
2016-03-15 15:02
快速回复:windows下Python调用Python出现error LNK2019
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014373 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved