mitmproxy / pdoc

API Documentation for Python Projects
https://pdoc.dev
MIT No Attribution
1.97k stars 196 forks source link

PDoc Fails Locally #262

Closed Piphi5 closed 3 years ago

Piphi5 commented 3 years ago

Problem Description

PDoc has trouble importing some parts of the IPython Library on my local machine (both WSL and windows). This is the error message:

Traceback (most recent call last):
  File "c:\users\piphi\anaconda3\lib\site-packages\pdoc\extract.py", line 219, in load_module
    return importlib.import_module(module)
  File "c:\users\piphi\anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\piphi\documents\go-utils\go_utils\__init__.py", line 3, in <module>
    from go_utils.download import get_api_data
  File "c:\users\piphi\documents\go-utils\go_utils\download.py", line 7, in <module>
    from arcgis.features import GeoAccessor
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\__init__.py", line 4, in <module>
    from . import (features, geoanalytics, geocoding, geometry)
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\features\__init__.py", line 28, in <module>
    from . import enrich_data
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\features\enrich_data.py", line 10, in <module>
    import arcgis.network as network
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\network\__init__.py", line 7, in <module>
    from ._layer import NetworkLayer, NetworkDataset, ClosestFacilityLayer, ServiceAreaLayer, RouteLayer, NAJob, ODCostMatrixLayer
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\network\_layer.py", line 8, in <module>
    from arcgis.mapping import MapImageLayer
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\mapping\__init__.py", line 8, in <module>
    from ._types import WebMap, WebScene, MapImageLayer, MapImageLayerManager, VectorTileLayer, OfflineMapAreaManager, PackagingJob
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\mapping\_types.py", line 25, in <module>
    from arcgis.widgets._mapview._traitlets_extension import ObservableDict
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\widgets\__init__.py", line 2, in <module>
    from arcgis.widgets._mapview import MapView
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\widgets\_mapview\__init__.py", line 1, in <module>
    from arcgis.widgets._mapview._mapview import MapView
  File "c:\users\piphi\anaconda3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py", line 21, in <module>
    import ipywidgets
  File "c:\users\piphi\anaconda3\lib\site-packages\ipywidgets\__init__.py", line 23, in <module>
    from IPython import get_ipython
  File "c:\users\piphi\anaconda3\lib\site-packages\IPython\__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "c:\users\piphi\anaconda3\lib\site-packages\IPython\terminal\embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "c:\users\piphi\anaconda3\lib\site-packages\IPython\terminal\interactiveshell.py", line 3, in <module>
    import asyncio
  File "c:\users\piphi\anaconda3\lib\asyncio\__init__.py", line 35, in <module>
    tasks.__all__ +
NameError: name 'base_events' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\piphi\anaconda3\lib\site-packages\pdoc\web.py", line 73, in handle_request
    mod = doc.Module(extract.load_module(module))
  File "c:\users\piphi\anaconda3\lib\contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "c:\users\piphi\anaconda3\lib\site-packages\pdoc\extract.py", line 221, in load_module
    raise RuntimeError(f"Error importing {module}") from e
RuntimeError: Error importing go_utils

However, when I build it on Github actions, it has no issues: https://iges-geospatial.github.io/globe-observer-utils-docs/.

Steps to reproduce the behavior:

  1. pip install go_utils
  2. pdoc go_utils

System Information

pdoc: 7.0.1 Python: 3.7.6 Platform: Windows-10-10.0.19041-SP0

mhils commented 3 years ago

Thanks! That looks like a bug, at least it clearly shouldn't crash. I suppose you can probably run pdoc locally with -o outdir and that should work, but we'll get that fixed anyhow. :)

Piphi5 commented 3 years ago

It seems like writing to an output still fails locally. Not sure why it works fine on the Actions Machines

mhils commented 3 years ago

Ok, after look at this a bit longer, I'm not convinced anymore that this is a pdoc issue. I thought you'd see pdoc crashing, but it looks like pdoc is catching the crash gracefully and just showing you the error message.

I can reproduce this neither on Windows nor under WSL. The traceback also makes me believe this is more about your Python installation than anything else. Can you import asyncio on your system?

Piphi5 commented 3 years ago

I also agree that this most likely isn't a pdoc bug (I just didn't know where else to get help troubleshooting it) since it builds fine on the GH actions machines.

I can import ayncio image

Piphi5 commented 3 years ago

I managed to resolve the issue by creating a new Conda environment and then I had to upgrade Jedi to the latest version. Not really sure why that worked, but this issue should be closed.