Visual Studio pyclipper安装错误:“tp_print不是类型对象的成员”

klh5stk1  于 2023-01-21  发布在  其他
关注(0)|答案(3)|浏览(256)

我正在尝试安装pyclipper以与nototools. https://github.com/googlefonts/nototools一起使用,但我无法安装pyclipper。我认为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 ```
btxsgosb

btxsgosb1#

在Python 3.9中,tp_print方法从API中被移除。错误“'tp_print':is not a member of '_typeobject'”意味着这段代码适用于Python〈= 3.8。
请降级到Python 3.8并重试。

  • Upd*. pyclipper刚刚发布了1.2.1版本,带有Python 3.9的wheels。

PS.永远不要急于更新Python的主要版本,等到你所有的第三方库都适应了。

xvw2m8pv

xvw2m8pv2#

正如@phd正确指出的那样,从Python 3.9开始,tp_print就被删除了。在此(以及其他类似的问题)C/C 代码是由Cython生成的,而不是手写的。Cython制作扩展模块的好处之一是它可以维护,并且可以跟上Python的变化。因此,只需重新生成C/C 代码,就可以很容易地使模块再次兼容用最新版本的Cython编写代码。
对于这个特定的例子,PyClipper包含两种构建模块的方法:第一种方法只是编译预先生成的C
代码,而第二种方法使用Cython重新生成C
代码,使用第二种方法重新生成代码就可以解决您的问题。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.
碰巧的是,PyClipper现在已经更新了他们自己的模块,所以这不再是必要的,但是对于其他因为类似错误而失败的模块,值得考虑用新版本的Cython重新生成C/C ++代码。

lp0sw83n

lp0sw83n3#

我的解决方案非常简单,把下面的 requirements 放到 buildozer.spec 文件中,其中的版本号(即3.6.9)与我安装在系统中的python版本相匹配

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3==3.6.9, hostpython3==3.6.9

这就消除了我所有的cython错误,builodozer完成了构建,这样我就有了一个可以安装的bin文件。
作为一个警告,这对我来说不是故事的结尾;然后是lead to this error,我还没有找到解决方案。

相关问题