2

I'm trying to install pyCLD3 on Windows 10 (python 3.8.5):

pip install pycld3 on Windows does not work (as expected, it's mentioned in the README file on their Github).

However, the instructions how to install it from Source are not clear, it only states that I need some prerequisites and gives an unclear reference on how to install one of them (Protobuf), but not the others and not how to proceed to install pyClD3 itself.

enter image description here

I managed to install Protoc using Chocolatey consulting this post, however, I'm not sure if that's how I should have done it and how to proceed next, i.e. what are the Protobuf development headers and where to find libprotoc library - is it the same thing as Protobuf/protoc? As for g++, I have installed MinGW from here, but also confused what to do with it next.

Here is a snippet of what I get when I try to install pyCLD3 using pip:

Building wheels for collected packages: pycld3
  Building wheel for pycld3 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
<...>
Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpcld3/pycld3.cpp /Fobuild\temp.win-amd64-3.8\Release\cld3/pycld3.obj -std=c++11
  cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
  pycld3.cpp
  C:\Users\me\AppData\Local\Temp\pip-install-1lgq4b5o\pycld3_11fb5b01d9d44711b4031f733ec7f6cc\src\cld_3/protos/feature_extractor.pb.h(10): fatal error C1083: Cannot open include file: 'google/protobuf/port_def.inc': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pycld3
Grintas
  • 46
  • 1
  • 5
  • Hello, pycld3 maintainer here. [This appears to be an issue with protobuf installation.](https://github.com/protocolbuffers/protobuf/issues/5868) Were you able to resolve it? – Brad Solomon Mar 12 '21 at 11:57

1 Answers1

1

You may try Msys2. I managed to compile pycld3 in Windows 10 with Python3.7.

In Windows 10's cmd

  • download pycld3-0.20.tar.gz from https://pypi.org/project/pycld3/#files, untar it and cd to that directory
  • creatae a Py3.7 virtual environ (py -3.7 -m venv venv). (I dont know whether other Python versions work or not.)

Msys2

  • install msys2 https://www.msys2.org/
  • start msys2 (c:\msys64\msys2.exe)
  • update msys2: do a few pacman -Syuu as necessary
  • install the toolchain (pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make)
  • install protoc (pacman -S mingw-w64-x86_64-protobuf, protoc installed by choco didnt work in my experiment but this protoc works)
  • setup PATH (export PATH=$PATH:/mingw64/bin/)
  • insert a #include <math.h> line before line 6 of Python.h (e.g C:\Python\Python37\include\Python.h in my case). This fixed the _hypot related errors.
  • compile and install (go to the directory above, e.g. cd /c/Users/xyz/Downloads/pycld3-0.20/pycld3-0.20 and execute ./venv/Scripts/python.exe setup.py build)

I managed to successfully build pycld3 but was unable to isntall -- got some ValueError: ZIP does not support timestamps before 1980 error when I tried venv/Scripts/python setup.py install.

Please accept my answer if it fixes your 'google/protobuf/port_def.inc': No such file or directory problem:).

mikey
  • 2,158
  • 1
  • 19
  • 24