Я новичок в расширении Python C.Я копирую простой пример, который печатает «Привет мир».Но система продолжает говорить «ошибка: [WinError 2] Системе не удается найти указанный файл».
setup.py
:
from distutils.core import setup, Extension
setup(name = 'myModule',
version = '1.0',
ext_modules = [Extension('myModule', ['myModule.c'])])
myModule.c
:
#include <Python.h>
// Function 1: A simple 'hello world' function
static PyObject* helloworld(PyObject* self, PyObject* args)
{
printf("Hello World\n");
return Py_None;
}
// Our Module's Function Definition struct
// We require this `NULL` to signal the end of our method
// definition
static PyMethodDef myMethods[] = {
{ "helloworld", helloworld, METH_NOARGS, "Prints Hello World" },
{ NULL, NULL, 0, NULL }
};
// Our Module Definition struct
static struct PyModuleDef myModule = {
PyModuleDef_HEAD_INIT,
"myModule",
"Test Module",
-1,
myMethods
};
// Initializes our module using our above struct
PyMODINIT_FUNC PyInit_myModule(void)
{
return PyModule_Create(&myModule);
}
Я попытался изменить все строки 404 out_string = check_output(['gcc', '-dumpmachine'])
в файлах cygwincompiler.py
, которые я смог найти, на out_string = check_output(['gcc', '-dumpmachine'], shell=True)
"Все еще не повезло.
В моем коде есть основная ошибка? Я слышал, чтоc Имя исходного файла не имеет значения. Вот изображение терминала