user@Embedded-10:~/python_programs$ pip install Tkinter
Collecting Tkinter
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 795, in get_page
resp.raise_for_status()
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/tkinter/
答案1
无需使用pip
for installation Tkinter
(版本 2.x) 或pip3
for installation tkinter
(版本 3.x)。它们在 Ubuntu 中是本地可用的,您可以同时安装两个版本。从维基百科:
特金特是 Tk GUI 工具包的 Python 绑定。它是 Tk GUI 工具包的标准 Python 接口,2并且是 Python 事实上的标准 GUI。3Tkinter 包含在 Python 的标准 Linux、Microsoft Windows 和 Mac OS X 安装中。
我自己确实需要安装 Pillow(PIL 的分支)来进行图像处理。在这种情况下,您仍然不需要pip
或pip3
,而是sudo apt install
使用。例如,这是我最近安装的:
$ grep " install " /var/log/dpkg.log | grep -i pil
2019-12-02 20:31:46 install python-pil:amd64 <none> 3.1.2-0ubuntu1.1
2019-12-04 16:43:04 install python-pil.imagetk:amd64 <none> 3.1.2-0ubuntu1.1
2019-12-04 16:43:11 install python3-pil.imagetk:amd64 <none> 3.1.2-0ubuntu1.1
2019-12-04 18:59:08 install python-pil-doc:all <none> 3.1.2-0ubuntu1.1
2019-12-04 18:59:10 install python-pil-dbg:amd64 <none> 3.1.2-0ubuntu1.1
2019-12-04 18:59:10 install python-pil.imagetk-dbg:amd64 <none> 3.1.2-0ubuntu1.1
使用 Pillow 成像,您可以在 Tkinter 画布中显示像屏幕截图一样的图像: