Python3.11.2 错误安装 tkfontawesome "python -m pip install tkfontawesome"

问题描述 投票:0回答:2

我正在尝试为 python 使用 Font Awesome,但我无法让它工作。

import tkinter as tk 
from tkfontawesome import icon_to_image 

root = tk.Tk() 

fb = icon_to_image("facebook", fill="#4267B2", scale_to_width=64) 
send = icon_to_image("paper-plane", fill="#1D9F75", 
scale_to_width=64)  
tk.Label(root, image=fb).pack(padx=10, pady=10) 
tk.Button(root, image=send).pack(padx=10, pady=10)  

root.mainloop()

这里有人知道怎么做吗?

我试过关注这篇文章,但似乎没有帮助。 FontAwesome 与 Python

这是错误:

Collecting tkfontawesome
  Using cached tkfontawesome-0.2.0-py3-none-any.whl (405 kB)
Collecting lxml==4.7.1
  Using cached lxml-4.7.1.tar.gz (3.2 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: tksvg==0.7.4 in 
c:\users\pamel\appdata\local\programs\python\python311\lib\site- 
packages (from tkfontawesome) (0.7.4)
Installing collected packages: lxml, tkfontawesome
  DEPRECATION: lxml is being installed using the legacy 'setup.py 
install' method, because it does not have a 'pyproject.toml' and 
the 'wheel' package is not installed. pip 23.1 will enforce this 
behaviour change. A possible replacement is to enable the '--use- 
pep517' option. Discussion can be found at 
https://github.com/pypa/pip/issues/8559
  Running setup.py install for lxml ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lxml did not run successfully.
  │ exit code: 1
  ╰─> [76 lines of output]
      Building lxml version 4.7.1.
      Building without Cython.
      Building against pre-built libxml2 andl libxslt libraries
      running install
  C:\Users\pamel\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
    warnings.warn(
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-311
  creating build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\builder.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\cssselect.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\doctestcompare.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\ElementInclude.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\sax.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\_elementpath.py -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\__init__.py -> build\lib.win-amd64-cpython-311\lxml
  creating build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\__init__.py -> build\lib.win-amd64-cpython-311\lxml\includes
  creating build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\builder.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\clean.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\defs.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\diff.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\formfill.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\html5parser.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\soupparser.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-cpython-311\lxml\html
  copying src\lxml\html\__init__.py -> build\lib.win-amd64-cpython-311\lxml\html
  creating build\lib.win-amd64-cpython-311\lxml\isoschematron
  copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-cpython-311\lxml\isoschematron
  copying src\lxml\etree.h -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\etree_api.h -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\lxml.etree.h -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-cpython-311\lxml
  copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\config.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\__init__.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-cpython-311\lxml\includes
  copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-cpython-311\lxml\includes
  creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources
  creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
  copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
  creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
  copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
  copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
  creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
  running build_ext
  building 'lxml.etree' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  [end of output]

注意:此错误源自子进程,可能不是 pip 的问题。 错误:遗留安装失败

× 尝试安装包时遇到错误。 ╰─> lxml

注意:这是上面提到的包的问题,不是pip。 提示:有关失败的输出,请参见上文。

python-3.x tkinter font-awesome tk-toolkit python-3.11
2个回答
0
投票
py -m pip install tkfontawesome

0
投票

我想通了。这仅适用于 Python3.10,不适用于 Python3.11。所以你需要下载并安装Python3.10,然后将你的解释器设置为Python3.10。

© www.soinside.com 2019 - 2024. All rights reserved.