Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyclipper installation error: "tp_print is not a member of _typeobject"

I'm trying to install pyclipper to use with nototools. https://github.com/googlefonts/nototools But I can't get pyclipper installed. I think there is something with Visual Studio buildtools.

Collecting pyclipper==1.1.0.post1
  Using cached pyclipper-1.1.0.post1.zip (135 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pyclipper
  Building wheel for pyclipper (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\phuwi\appdata\local\programs\python\python39\python.exe' 'c:\users\phuwi\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\phuwi\AppData\Local\Temp\tmpwa7t8eac'
       cwd: C:\Users\phuwi\AppData\Local\Temp\pip-install-ejg_l8me\pyclipper_be85d240fbf84e1388f6c535a16010eb
  Complete output (26 lines):
  Distribution mode: Compiling Cython generated .cpp sources.
  running bdist_wheel
  running build
  running build_ext
  building 'pyclipper' extension
  creating build
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\pyclipper
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\phuwi\appdata\local\programs\python\python39\include -Ic:\users\phuwi\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /EHsc /Tppyclipper/clipper.cpp /Fobuild\temp.win-amd64-3.9\Release\pyclipper/clipper.obj
  clipper.cpp
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\phuwi\appdata\local\programs\python\python39\include -Ic:\users\phuwi\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /EHsc /Tppyclipper/pyclipper.cpp /Fobuild\temp.win-amd64-3.9\Release\pyclipper/pyclipper.obj
  pyclipper.cpp
  pyclipper/pyclipper.cpp(7938): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  pyclipper/pyclipper.cpp(8068): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  pyclipper/pyclipper.cpp(9405): error C2039: 'tp_print': is not a member of '_typeobject'
  c:\users\phuwi\appdata\local\programs\python\python39\include\cpython/object.h(193): note: see declaration of '_typeobject'
  pyclipper/pyclipper.cpp(9413): error C2039: 'tp_print': is not a member of '_typeobject'
  c:\users\phuwi\appdata\local\programs\python\python39\include\cpython/object.h(193): note: see declaration of '_typeobject'
  pyclipper/pyclipper.cpp(9421): error C2039: 'tp_print': is not a member of '_typeobject'
  c:\users\phuwi\appdata\local\programs\python\python39\include\cpython/object.h(193): note: see declaration of '_typeobject'
  pyclipper/pyclipper.cpp(9427): error C2039: 'tp_print': is not a member of '_typeobject'
  c:\users\phuwi\appdata\local\programs\python\python39\include\cpython/object.h(193): note: see declaration of '_typeobject'
  pyclipper/pyclipper.cpp(10553): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3
  pyclipper/pyclipper.cpp(10569): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  ERROR: Failed building wheel for pyclipper
Failed to build pyclipper
ERROR: Could not build wheels for pyclipper which use PEP 517 and cannot be installed directly ```
like image 449
Phuwit Puthipiroj Avatar asked Dec 27 '20 02:12

Phuwit Puthipiroj


2 Answers

The tp_print method was removed from the API in Python 3.9. Error "'tp_print': is not a member of '_typeobject'" means that the code is intended for Python <= 3.8.

Downgrade to Python 3.8 and try again.

Upd. pyclipper just released version 1.2.1 with wheels for Python 3.9.

PS. Never hurry to a newer major version of Python, wait until all your 3rd-party libraries adapt.

like image 66
phd Avatar answered Nov 10 '22 07:11

phd


As @phd correctly points out, tp_print is dropped from Python 3.9 onwards. However, in this (and other similar questions) the C/C++ code is generated by Cython rather than handwritten. One of the benefits of Cython for making extension modules is that it is maintained and does keep up with changes in Python. Therefore modules are readily made compatible again simply by regenerating the C/C++ code with an up-to-date version of Cython.

For this specific case PyClipper contains two ways of building the module: https://github.com/fonttools/pyclipper/blob/master/README.rst#install. The first just compiles the pre-generated C++ code while the second regenerates the C++ code using Cython. Using the second method to rebuild it would have solved your problem.

As it happens, PyClipper have updated their own module now so this is no longer necessary, but for other modules that are failing with similar errors it's worth looking at regenerating the C/C++ code with a newer version of Cython.

like image 27
DavidW Avatar answered Nov 10 '22 07:11

DavidW