Bug 140279 - Embedded Python install missing 6 Windows DLL files (LO 7.1.0.3, Python 3.8.4)
Summary: Embedded Python install missing 6 Windows DLL files (LO 7.1.0.3, Python 3.8.4)
Status: RESOLVED DUPLICATE of bug 140236
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Installation (show other bugs)
Version:
(earliest affected)
7.1.0.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 140278 (view as bug list)
Depends on: python-core-3.8.4
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-08 21:49 UTC by Helio Asteroid
Modified: 2021-02-19 06:10 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helio Asteroid 2021-02-08 21:49:46 UTC
Description:
After upgrading from LO 7.0 to 7.1.0.3, I am unable to install "pip" using "get-pip.py" on a Windows 10 PC. Traceback from get-pip shows error
  FileNotFoundError: [WinError 2] The system cannot find the file specified 
However, as explained below, the error / traceback are a bit of a red herring. I think the real issue is that 6 DLL files are missing from the embedded python installation delivered with LO 7.1.0.3.

There is a workaround, but it would not be easy for non-technical users.

Steps to Reproduce:
1. Perform standard upgrade installation of LO 7.1.0.3 on Windows 10 PC
2. Open administrator powershell
2a. cd 'C:\Program Files\LibreOffice\program\'
2b. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2c. .\python.exe .\get-pip.p

Actual Results:
PS C:\Program Files\LibreOffice\program> .\python  .\get-pip.py

Traceback (most recent call last):
  File "C:\Program Files\LibreOffice\program\get-pip.py", line 24244, in <module>
    main()
  File "C:\Program Files\LibreOffice\program\get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "C:\Program Files\LibreOffice\program\get-pip.py", line 177, in bootstrap
    sys.exit(pip_entry_point(args))
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\cli\main.py", line 58, in main
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\cli\main_parser.py", line 67, in parse_command
  File "C:\Program Files\LibreOffice\program\python-core-3.8.4\lib\optparse.py", line 1371, in parse_args
    values = self.get_default_values()
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\cli\parser.py", line 267, in get_default_values
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\configuration.py", line 137, in load
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\configuration.py", line 259, in _load_config_files
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\configuration.py", line 362, in iter_config_files
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\configuration.py", line 78, in get_configuration_files
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_internal\utils\appdirs.py", line 38, in site_config_dirs
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_vendor\appdirs.py", line 243, in site_config_dir
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_vendor\appdirs.py", line 138, in site_data_dir
  File "C:\Users\xxx\AppData\Local\Temp\tmp7utwaimk\pip.zip\pip\_vendor\appdirs.py", line 486, in _get_win_folder_from_registry
FileNotFoundError: [WinError 2] The system cannot find the file specified

Expected Results:
PS C:\Program Files\LibreOffice\program> .\python  .\get-pip.py
Collecting pip
  Using cached pip-21.0.1-py3-none-any.whl (1.5 MB)
Collecting setuptools
  Downloading setuptools-53.0.0-py3-none-any.whl (784 kB)
     |████████████████████████████████| 784 kB 85 kB/s
Collecting wheel
  Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
  WARNING: The script wheel.exe is installed in 'C:\Program Files\LibreOffice\program\python-core-3.8.4\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pip.exe, pip3.8.exe and pip3.exe are installed in 'C:\Program Files\LibreOffice\program\python-core-3.8.4\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.0.1 setuptools-53.0.0 wheel-0.36.2
PS C:\Program Files\LibreOffice\program>


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Possible workaround:
I suspected that some Windows-specific files might be missing from the embedded python distribution included with LO 7.1.0.3. Using source from https://www.python.org/ftp/python/3.8.4, I first checked *.pyd files, but they all seemed to be present (though I only spot-checked, did not exhaustively compare).  Next I checked *.DLL files and found only 2 on the target PC, but 8 in the master ZIP file.  See list below:


 Status                 Name
 ------                 ----
 present                libcrypto-1_1.dll
 present                libssl-1_1.dll

 Missing                libffi-7.dll
 Missing                python3.dll
 Missing                python38.dll
 Missing                sqlite3.dll
 Missing                vcruntime140.dll
 Missing                vcruntime140_1.dll
  

After copying the 6 missing DLL files to: 
    C:\Program Files\LibreOffice\program\python-core-3.8.4\lib\
I re-ran step 2c above and succeeded in installing pip.  I was also able to install other packages using pip.  I have not done any further testing, but it seems this might be a workaround until the problem is resolved (though not suitable for non-technical users).
Comment 1 Helio Asteroid 2021-02-08 21:55:24 UTC
*** Bug 140278 has been marked as a duplicate of this bug. ***
Comment 2 Dan 2021-02-14 11:51:09 UTC
It works! LO 7.1.0.3 and Python 3.8.4
Comment 3 Ming Hua 2021-02-14 17:14:41 UTC
Dear Jan-Marek Glogowski,

Since you are the author of commit https://git.libreoffice.org/core/+/b4dfba947768834ffecc09056992019878711c8b that upgraded Python to 3.8.4, and the commit log explicitly mentions libffi DLL, I think you may be interested in this one.
Comment 4 Jan-Marek Glogowski 2021-02-15 12:31:59 UTC
AFAIK the only missing library is libffi-7.dll (see bug 140236). The rest of them is available either on the system (vcruntime*) or in the program directory (python*.dll, sqlite3.dll). That sqlite3.dll is actually from the NSS build, as LO doesn't build python with sqlite.

I don't know how the "missing" list was created, but I guess it was some trial and error. My guess is, that adding the libffi-7.dll is enough and that is already fixed. Can you verify this?
Comment 5 Helio Asteroid 2021-02-18 21:05:45 UTC
Adding libffi-7.dll did resolve my issue.

I'm not sure if it's appropriate to mention here, or if you'd prefer separate bug report(s): I find that each time I upgrade LibreOffice (LO), iff LO has embedded a new Python version, then extra python packages I installed (residing in directory "site-packages") over the previous months/years are wiped out, and I must rebuild the environment required by my LO python macros.  For that reason, I now religiously check the Release Notes before upgrading LO to see if a new version of Python is included.
1. LO 7.1.0.3 Rel Notes did not (at least, not when I read them) mention the new python version.  Could the Rel Notes be updated to help others?
2. Not sure if this is reasonable / advisable, but is it possible for the installation process to automatically preserve the LO user's python package environment in cases where LO is delivering a new python version?
3. If answer to #2 is no, is there any way to at least include pip (or somehow boostrap pip automatically) in the embedded python?  That would simplify re-establishing the package environment needed by LO user's python macros.

Thanks for resolving the DLL issue.  Let me know if one or more of items 1-3 belong in a separate bug report.
Comment 6 Jan-Marek Glogowski 2021-02-19 06:10:07 UTC
(In reply to gaxonegaxone from comment #5)
> Adding libffi-7.dll did resolve my issue.

Ok. I'll close this as a duplicate.

> I'm not sure if it's appropriate to mention here, or if you'd prefer
> separate bug report(s): I find that each time I upgrade LibreOffice (LO),
> iff LO has embedded a new Python version, then extra python packages I
> installed (residing in directory "site-packages") over the previous
> months/years are wiped out, and I must rebuild the environment required by
> my LO python macros.  For that reason, I now religiously check the Release
> Notes before upgrading LO to see if a new version of Python is included.

> 1. LO 7.1.0.3 Rel Notes did not (at least, not when I read them) mention the
> new python version.  Could the Rel Notes be updated to help others?

Adding that info to the release notes is easy enough, if people don't forget it, even that I don't see any benefit. You would see a failure instantly anyway.

> 2. Not sure if this is reasonable / advisable, but is it possible for the
> installation process to automatically preserve the LO user's python package
> environment in cases where LO is delivering a new python version?

Probably. The install directory currently contains a version (program/python-core-<version>). We build + ship our own Python for user convenience and because pyuno is a c++ modules, so it would need to be compiled on a users computer. I don't know, how compatible the Python module interface is, so we could optionally use some system Python on Windows too and just ship a precompiled PyUNO version. So maybe that workaround wouldn't actually work. And it makes things much more complicated and error prone in the end.

And if we eliminate the version postfix, I'm not sure that would help or produce more problems, if python versions break stuff. Maybe other stuff relies on this directory name too.

This all looks like a can of worms and I doubt that currently any dev would invest time into this. You're free to try yourself, or propose some solution.

In any way, this should be an extra bug report for further discussion.

> 3. If answer to #2 is no, is there any way to at least include pip (or
> somehow boostrap pip automatically) in the embedded python?  That would
> simplify re-establishing the package environment needed by LO user's python
> macros.

At least the Windows Python installer uses ensurepip to setup pip. I have no idea, if that call is actually enough, or if there is additional stuff missing in LO's Python build. The documentation claims, that everything is already available and just work: https://docs.python.org/3/library/ensurepip.html

The msi call is "python -E -s -m ensurepip -U --default-pip", so I assume it works on Windows too, if LO doesn't skip any pip stuff.

> Thanks for resolving the DLL issue.

You're welcome.

> Let me know if one or more of items 1-3 belong in a separate bug report.

*** This bug has been marked as a duplicate of bug 140236 ***