BUG: pydoc.ErrorDuringImport when using pydoc to see docs
- [x] I have checked that this issue has not already been reported.

- [x] I have confirmed this bug exists on the latest version of pandas.

- [ ] (optional) I have confirmed this bug exists on the master branch of pandas.

---

**Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to provide the necessary information for us to reproduce your bug.

#### Code Sample, a copy-pastable example

```bash
pydoc -p 8000
```

#### Problem description

I tried to use pydoc to view documentation of pandas offline and it works fine at most time. When I want to view docs of DataFrame, I click the link and it brings me to `http://localhost:8000/pandas.core.frame.html`. However, it just shows an error like this
```
pandas.core.frame.html
--
pydoc.ErrorDuringImport: problem in pandas.core.frame - ImportError: cannot import name 'concat_compat' from partially initialized module 'pandas.core.dtypes.concat' (most likely due to a circular import) (/home/user/.local/lib/python3.9/site-packages/pandas/core/dtypes/concat.py)
```
![image](https://user-images.githubusercontent.com/24590067/111029318-0f518300-8437-11eb-991c-028cd39a99ec.png)
I have tested on different platforms, from Windows 7 to Arch Linux, from Python 3.6 with Anaconda to Python 3.9. And the problem remains the same. In addition, some other pydoc page in `core` hava similar problems.

Just now I found that `pydoc -w pandas.core.frame` create correct html file for the documentation! That is interesting :smile: 
 
#### Expected Output
It should show the documentation page.

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : 3e89b4c4b1580aa890023fc550774e63d499da25
python           : 3.9.2.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.10.19-1-MANJARO
Version          : #1 SMP PREEMPT Fri Feb 26 11:38:34 UTC 2021
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.2.0
numpy            : 1.20.1
pytz             : 2021.1
dateutil         : 2.8.1
pip              : 21.0
setuptools       : 53.1.0
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : 4.6.2
html5lib         : 1.1
pymysql          : None
psycopg2         : None
jinja2           : 2.11.3
IPython          : 7.19.0
pandas_datareader: None
bs4              : 4.9.3
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : 3.3.4
numexpr          : None
odfpy            : None
openpyxl         : 3.0.5
pandas_gbq       : None
pyarrow          : 3.0.0
pyxlsb           : None
s3fs             : None
scipy            : 1.6.0
sqlalchemy       : None
tables           : None
tabulate         : 0.8.9
xarray           : None
xlrd             : 1.2.0
xlwt             : None
numba            : None
None

</details>

I have searched for this problem and it seems that there have been no discussion about it, so I submit this issue to report this weird behavior to you although it may not be your responsibility. But I cannot find place to make issue regarding to `pydoc` :cry: 

I found this error out put in the [`CPython`](https://github.com/python/cpython/blob/master/Python/ceval.c) code below (at line 6135), hoping this will help you. And that is why I submit this issue as BUG instead of DOC, since it says `due to a circular import`.

```C
static PyObject *
import_from(PyThreadState *tstate, PyObject *v, PyObject *name)
{
    PyObject *x;
    PyObject *fullmodname, *pkgname, *pkgpath, *pkgname_or_unknown, *errmsg;

    if (_PyObject_LookupAttr(v, name, &x) != 0) {
        return x;
    }
    /* Issue #17636: in case this failed because of a circular relative
       import, try to fallback on reading the module directly from
       sys.modules. */
    pkgname = _PyObject_GetAttrId(v, &PyId___name__);
    if (pkgname == NULL) {
        goto error;
    }
    if (!PyUnicode_Check(pkgname)) {
        Py_CLEAR(pkgname);
        goto error;
    }
    fullmodname = PyUnicode_FromFormat("%U.%U", pkgname, name);
    if (fullmodname == NULL) {
        Py_DECREF(pkgname);
        return NULL;
    }
    x = PyImport_GetModule(fullmodname);
    Py_DECREF(fullmodname);
    if (x == NULL && !_PyErr_Occurred(tstate)) {
        goto error;
    }
    Py_DECREF(pkgname);
    return x;
 error:
    pkgpath = PyModule_GetFilenameObject(v);
    if (pkgname == NULL) {
        pkgname_or_unknown = PyUnicode_FromString("<unknown module name>");
        if (pkgname_or_unknown == NULL) {
            Py_XDECREF(pkgpath);
            return NULL;
        }
    } else {
        pkgname_or_unknown = pkgname;
    }

    if (pkgpath == NULL || !PyUnicode_Check(pkgpath)) {
        _PyErr_Clear(tstate);
        errmsg = PyUnicode_FromFormat(
            "cannot import name %R from %R (unknown location)",
            name, pkgname_or_unknown
        );
        /* NULL checks for errmsg and pkgname done by PyErr_SetImportError. */
        PyErr_SetImportError(errmsg, pkgname, NULL);
    }
    else {
        _Py_IDENTIFIER(__spec__);
        PyObject *spec = _PyObject_GetAttrId(v, &PyId___spec__);
        const char *fmt =
            _PyModuleSpec_IsInitializing(spec) ?
            "cannot import name %R from partially initialized module %R "
            "(most likely due to a circular import) (%S)" :
            "cannot import name %R from %R (%S)";
        Py_XDECREF(spec);

        errmsg = PyUnicode_FromFormat(fmt, name, pkgname_or_unknown, pkgpath);
        /* NULL checks for errmsg and pkgname done by PyErr_SetImportError. */
        PyErr_SetImportError(errmsg, pkgname, pkgpath);
    }

    Py_XDECREF(errmsg);
    Py_XDECREF(pkgname_or_unknown);
    Py_XDECREF(pkgpath);
    return NULL;
}
```