After embeding a Python module into a C app., when running it, errors poped,
ImportError: No module named pyfunction
The solution is
1) in a Console, run
gcc first.c -o first `python-config --cflags` `python-config --ldflags`
PYTHONPATH=. ./first
2) a second alternative solution is
after building the c file as above, run with the folowing shell:
#OK
export PYTHONPATH=./first
first/first
This is also OK
本文介绍了如何解决在将Python模块嵌入C应用程序时遇到的ImportError错误。提供了两种解决方案:一种是在命令行中运行gcc,并使用python-config获取必要的编译参数;另一种是在构建C文件后,通过环境变量设置PYTHONPATH来运行应用程序。
2万+

被折叠的 条评论
为什么被折叠?



