博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pyenv Install tkinter on macOS
阅读量:3938 次
发布时间:2019-05-23

本文共 1821 字,大约阅读时间需要 6 分钟。

错误信息

import turtleTraceback (most recent call last):  File "
", line 1, in
File "~/.pyenv/versions/3.7.4/lib/python3.7/turtle.py", line 107, in
import tkinter as TK File "~/.pyenv/versions/3.7.4/lib/python3.7/tkinter/__init__.py", line 36, in
import _tkinter # If this fails your Python may not be configured for TkModuleNotFoundError: No module named '_tkinter'

install pyenv via homebrew

$brew install pyenv

install tcl-tk via home brew

$brew install tcl-tk

to get tcl-tk 8.6 to work with the pyenv install of python, you must

edit the python-build script file. It may be located in one these two locations:

~/.pyenv/plugins/python-build/bin/python-build

or:

/usr/local/Cellar/pyenv/1.2.13/plugins/python-build/bin/python-build

Once you have the script file open, search for:

$CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}" || return 1
and replace with:
$CONFIGURE_OPTS --with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6' ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}" || return 1

install Python 3.7.4 in pyenv

$pyenv install 3.7.4

set the default python version via the global variable and check it

$pyenv global 3.7.4
$pyenv version

Add to your .bash_profile to set the pyenv every time you load your shell

$echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

reset your shell

$exec "$SHELL"

check your environment

$which python$python -V$which pip$pip -V

(check if your pip needs upgrading with $pip install --upgrade pip)

Test your tcl-tk installation with $python -m tkinter -c ‘tkinter._test()’

If you don’t get any errors when running the above test, your installation should work

转载地址:http://xnywi.baihongyu.com/

你可能感兴趣的文章
SQL中 EXCEPT、INTERSECT用法
查看>>
SQL Server中VARCHAR(MAX)和NVARCHAR(MAX)的使用(转载)
查看>>
C# 对json字符串转换操作
查看>>
jQuery plugin: Validation 使用说明
查看>>
外部程序用process.start调用 其它exe文件时可以传入参数.
查看>>
动态 增加/删除 控件的关联事件
查看>>
Datagridview 相关
查看>>
一个带事务的Sql Server存储过程例子
查看>>
VS WinForm 中 父Datagridview嵌套子DatagridView
查看>>
Winform datagridview绑定数据源后,无法以 Rows.Insert方法插入新行
查看>>
Linq平行作業的例子
查看>>
Datagridview 綁定list注意事項(轉)
查看>>
DataGridView綁定數據相關
查看>>
合并兩個List,對方不存在相等的元素.則用null代替
查看>>
Linq GroupJoin(一)
查看>>
C#利用正则表达式获取特定格式的字串符
查看>>
C#将Excel文件中选择的内容,复制粘贴到 winform datagridview
查看>>
SQL 判断当前数据库是否存在某个表/临时表
查看>>
SQL列出数据库表的结构
查看>>
關于Enumerable distinct 的學習筆記
查看>>