Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么在使用distutils构建C扩展时会出现无法识别的命令行错误_Python_Compiler Construction_Distutils_Setup.py - Fatal编程技术网

Python 为什么在使用distutils构建C扩展时会出现无法识别的命令行错误

Python 为什么在使用distutils构建C扩展时会出现无法识别的命令行错误,python,compiler-construction,distutils,setup.py,Python,Compiler Construction,Distutils,Setup.py,我正在尝试使用python的distutils构建源代码。我已经创建了一个简单的setup.py,并按照建议进行了构建: python setup.py build 现在可以使用所需的编译器构建源代码;编译器列表 但是,例如,如果我尝试使用mingw32编译器,如下所示 python setup.py build --compiler=mingw32 我得到以下错误输出: building 'demo' extension creating build creating build/temp

我正在尝试使用
python
distutils
构建源代码。我已经创建了一个简单的
setup.py
,并按照建议进行了构建:

python setup.py build
现在可以使用所需的编译器构建源代码;编译器列表

但是,例如,如果我尝试使用
mingw32
编译器,如下所示

python setup.py build --compiler=mingw32
我得到以下错误输出:

building 'demo' extension
creating build
creating build/temp.linux-i686-2.7
gcc -mno-cygwin -mdll -O -Wall -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.7 -c demo.c -o build/temp.linux-i686-2.7/demo.o
cc1: error: unrecognized command line option ‘-mno-cygwin’
cc1: error: unrecognized command line option ‘-mdll’
error: command 'gcc' failed with exit status 1

这个问题的原因是什么?我做错什么了吗?我是否需要指定其他内容?我是否使用了错误的版本(Ubuntu12.04、Python2.7.3、Distutils 1.0a4)?我是否需要“删除”有问题的选项?

我认为你在Ubuntu上没有MinGW

正如你已经引述的

--compiler=mingw32  Mingw32 port of GNU C Compiler for Win32

您应该改为尝试
--compiler=unix

您可以尝试安装python开发头,然后运行命令吗

sudo apt-get install python-dev
sudo apt-get install libevent-dev

啊,我明白了。我刚刚通过运行
sudo-apt-get-install gcc-mingw32
安装了
mingw32
,但我仍然收到相同的错误。我认为这不会影响所使用的编译器选项和/或编译器对它们的理解。
sudo apt-get install python-dev
sudo apt-get install libevent-dev