I am tying to modify the original sklearn.CalibrationCV
to create my won version. The original code has "from.utils.fixes import signature". So I did the following in my version:
from sklearn.utils.fixes import signature
but got a error:
ImportError: cannot import name signature
When check the sklearn source code on GitHub. I see the following code inside fixes.py
:
try:
from inspect import signature
except ImportError:
from ..externals.funcsigs import signature
Then I did from inspect import signature
directly. Still get " ImportError: cannot import name signature
"
Besides how to fix this, I am also curious about why the original version can import a module that will be imported from another source? Thanks.
inspect
module does not have a signature
method.inspect
module does have a signature
method.This code is just trying to work with both python 2 and 3.
You may want to use the funcsigs
module if you are using python 2, or use sklearn.externals.funcsigs
directly (for version sklearn >= 0.17
).
The accepted answer doesn't work with the latest version of sklearn.
Please install funcsigs
directly using
pip install funcsigs
and use from funcsigs import signature
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.