error: each element of 'ext_modules' option must be an Extension instance or 2-tuple

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

I am trying to use setuptools in python to create an egg package, but I get this weird error:

error: each element of 'ext_modules' option must be an Extension instance or 2-tuple 

How can I fix this?

回答1:

Assuming that you already have setuptools installed, Edit setup.py of the egg package target and replace the import setup, Extension in order to get them from setuptools.

from setuptools import setup, Extension, Command 

Rational: setuptools redefines Extension so it's possible that it does not recognize the object that you have in the ext_modules argument as a valid Extension object. Hence the error message.

ext_modules is one of the arguments of setup() method that describe the extension of your module, and it's specified in setup.py.

setup(name='foo',   version='1.0',   ext_modules=[Extension('foo', ['foo.c'])],   )  

More info available in Python documentation



回答2:

This happens due to conflict with distutils from where the Extension is imported w.r.t setuptools. I see this error when installing gdsCAD so I had to update the setupext.py to sucessfully install



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!