PyAr / CDPedia

CDPedia is a project to make the Wikipedia accesable offline
34 stars 15 forks source link

Embedded python fails to launch CDPedia on Windows #327

Closed fzuccolo closed 3 years ago

fzuccolo commented 3 years ago

Description

In Windows, running cdpedia.bat (or python\python.exe cdpedia.py) from image root fails:

Traceback (most recent call last):
  File "cdpedia.py", line 36, in <module>
    import config  # NOQA
ModuleNotFoundError: No module named 'config'

Reason

The embeddable python for windows comes with a python*._pth file that overrides sys.path at runtime and by design the current working directory is not included. As config.py is now in the image root (the cwd), cdpedia.py can't find it.

Reference: https://docs.python.org/3/using/windows.html#finding-modules

Solution

Delete any *._pth file from embedded python directory to restore sys.path normal behaviour (having cwd as first item)