Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Ubuntu上的python3.6中安装tkinter_Python_Python 3.x_Tkinter_Tcl_Python 3.6 - Fatal编程技术网

在Ubuntu上的python3.6中安装tkinter

在Ubuntu上的python3.6中安装tkinter,python,python-3.x,tkinter,tcl,python-3.6,Python,Python 3.x,Tkinter,Tcl,Python 3.6,由于Python3有两个版本,所以从存储库安装的任何东西都不适用于Python3.6。存储库中Python的最新版本是3.2,因此我需要源代码安装或通过pip3.6 启动python3.6后,我试图导入tkinter,这导致了以下错误。尽管help('modules')返回了包含tkinter的模块列表 +--------+-----------------------------------+ | OS | Ubuntu 12.04 | +--

由于Python3有两个版本,所以从存储库安装的任何东西都不适用于Python3.6。存储库中Python的最新版本是3.2,因此我需要源代码安装或通过pip3.6

启动
python3.6
后,我试图
导入tkinter
,这导致了以下错误。尽管
help('modules')
返回了包含tkinter的模块列表

+--------+-----------------------------------+
|   OS   |           Ubuntu 12.04            |
+--------+-----------------------------------+
| Python | 2.7, 3.2 and source installed 3.6 |
+--------+-----------------------------------+
我在python3.2中尝试了同样的操作,但是没有出现错误
tkinter.\u tkinter
给出了python3.2的tkinter库的位置

我将cd放入了包含所有库文件的
python3.6
目录,实际上它缺少
tkinter.so
对象文件

如何修复错误

我想让tkinter/tkagg正常工作,因为似乎所有的模块/包都已经安装好了

在谷歌搜索了一些之后,我发现我需要再次构建
python3.6
,但这次在运行configure时使用Tcl/Tk选项。我宁愿不要。从头开始安装
python3.6
大约需要1小时

有没有其他方法可以告诉我Tcl/Tk在哪里

问题不在于告诉python tcl/tk在哪里。在搞乱了python3.6的源代码,然后比较了python3.6和python3.2之后,我发现tkinter调用的是一个.so(共享对象)文件,python在安装过程中通过使用gcc的setup.py构建,它可能涉及到distutils,而不是python文件

新的更恰当的问题是我如何构建,
\u tkinter.cpython-36m-i386-linux-gnu.so
来自tcl/tk

注意:我确实安装了tcl/tk,我已使用tclsh和wish确认。

从终端运行:

 import tkinter
 ModuleNotFoundError: No module named '_tkinter'
或者完全重新安装:

sudo apt-get install python3.6-tk

试试这些台词,可能会有帮助

sudo apt-get install python3.6

执行前请重新检查路径。

我遇到了与您类似的问题,我将详细介绍它以及如何解决它

在Ubuntu 16.04 LTS上,我有Python3.5.2和Python2.7.12,但我想尝试Python3.6(出于各种原因,例如)。所以我依靠这个:

当我尝试使用tkinter运行模块时,收到以下错误消息:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
显然,我仍然不能将tkinter用于Python 3.6。如何解决这个问题

我的第一次盲目尝试没有成功:

sudo apt-get install python3-tk
[sudo] password for begueradj: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-tk is already the newest version (3.5.1-1).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
第二种方法有效:

sudo apt-get install python36-tk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python36-tk
这就解决了我的问题:

sudo apt-get install python3.6-tk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  tix python3.6-tk-dbg
The following NEW packages will be installed:
  python3.6-tk
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 74.6 kB of archives.
After this operation, 165 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 python3.6-tk amd64 3.6.5-1+xenial1 [74.6 kB]
Fetched 74.6 kB in 0s (301 kB/s)        
Selecting previously unselected package python3.6-tk:amd64.
(Reading database ... 324106 files and directories currently installed.)
Preparing to unpack .../python3.6-tk_3.6.5-1+xenial1_amd64.deb ...
Unpacking python3.6-tk:amd64 (3.6.5-1+xenial1) ...
Setting up python3.6-tk:amd64 (3.6.5-1+xenial1) ...
Python版本3.6.4(Ubuntu 18.04 LTS) 我遇到了相同的错误:找不到tkinter模块。即使在尝试通过pip安装之后
$pip安装tkinter
下面是我的错误

~/python3.6
Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> 
我尝试通过运行命令为Python3.6安装
tkinter
。它对我起了作用。
$sudo apt get install python3.6-tk

Python 3.6.4版(Ubuntu 18.04 LTS)

sudo add apt repository main

Collecting tkinter
  Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter

在ubuntu 20.04上安装了python3.8.2,尝试导入tkinter,但失败。出现以下错误: da0xxx:~/python\u trn/pygui$python3-mtkinter /usr/bin/python3:没有名为tkinter的模块

但他说:

da0xxx:~/python\u trn/pygui$sudo-apt-get-install-python3-tk

现在可以导入tkinter了

da0xxx:~/python\u trn/pygui$python3 Python 3.8.2(默认值,2020年4月27日,15:53:34) linux上的[GCC 9.3.0] 有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”

将tkinter作为tk导入


谢谢你

尝试从tkinter导入中执行
*
刚刚执行,给出了相同的错误@还有,我不会和tkinter一起工作,matplotlib是。我知道我应该,@Marvo,但我需要马上做一段时间。安装python3.6-tk@Boki,它不是那样工作的。12.04的ppa的最新python是3.2,deadsnakes的ppa的最新python是3.5,它只有核心python。为了便于获取,该包必须存在于ppa中。在搜索了近2个小时后,这就是对我实际有效的解决方案。非常感谢这对我不起作用
apt install python3.6-tk
显示“
注意,选择“python3-tk”而不是“python3.6-tk”
”,然后继续安装
python3-tk
~/python3.6
Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> 
Collecting tkinter
  Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
sudo apt-get install python3-tk