Skip to content

Issues installing distlib (and possibly other modules) as part of the create_deployment script

Robin Wilson edited this page Apr 5, 2020 · 1 revision

The create_deployment.ps1 script downloads and extracts an embedded version of Python, installs pip in that Python environment - and then uses pip to download and install the dependencies.

This seems to fail when the setup.py script imports the module itself - eg. when distlib's setup.py has the line import distlib in it. This is something to do with the way that embedded Python deals with paths differently to a standard installed version of Python. Using pip is not officially supported for embedded Python, but many people seem to have made it work successfully - apart from this issue. This has been discussed here.

At the moment, we have only experienced this issue with distlib, and have worked around it by including a distlib wheel file in the repository, and installing manually from that first. However, if we run into this with other packages that we need to install, then we may need to take a different approach.

The approach suggested here is to have a standard Python installation on the deployment machine, and use pip install --target to install into the embedded system's site-packages directory. This would be less 'neat' than our current approach as we'd have to have a standard Python install on the machine creating the deployment, and we'd be needing to switch between the standard Python install and the embedded Python install, but it should be possible if needed.