mpmath is a library intended to compute functions to high precision. If you try to use it on a symbolic variable it will fail. The input must be numeric (and Sage numbers work well)
sage: import mpmath