When import tkinter is not possible on Mac OS X 10.11.3 (El Capitan) + pyenv + Python 3.5.1.

What's wrong

If you start python in the above state and import tkinter, an import error will occur. There was information about the OS version of python, but not about this combination (although it wasn't too different).

import tkinter

Traceback (most recent call last):
  File "/var/folders/_w/52jb4hnx4hb3rv6pvdlb7gtm0000gp/T/login.py", line 2, in <module>
    import tkinter as tk
  File "/Users/hogehoge/.pyenv/versions/3.5.1/lib/python3.5/tkinter/__init__.py", line 35, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'

Solution

%Uninstall once
$ pyenv uninstall 3.5.1
% tcl-Install tk
$ brew tap Homebrew/dupes
$ brew install tcl-tk
%Install again
$ pyenv install 3.5.1

I was able to use it safely. It seems that --with-brewed-tk is required for python installed by brew, but this time it was not necessary to specify it.

I'm addicted to \ # zlib but this is solved with xcode-select --install

Recommended Posts

When import tkinter is not possible on Mac OS X 10.11.3 (El Capitan) + pyenv + Python 3.5.1.
Using NAOqi 2.4.2 Python SDK on Mac OS X El Capitan
Install python3 on Mac (El Capitan)
Build a python environment with pyenv (OS X El Capitan 10.11.3)
How to rebuild python environment from pyenv on Mac environment (El Capitan)
Install matplotlib on OS X El Capitan
Build an environment with pyenv, pyenv-virtualenv, jupyter on OS X El Capitan
Run Zookeeper x python (kazoo) on Mac OS X
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
Installing TensorFlow 0.11.0rc2 on OS X El Capitan (10.11.6)
Shpinx (Python documentation builder) on Mac OS X
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
Run Qiita API v2 Python wrapper in Python3 environment (Mac OS X 10.11 (El Capitan))
Build a Python development environment on Mac OS X
mac OS X 10.15.x pyenv Python If you can't install
Minimum memo when using Python on Mac (pyenv edition)
Suspend shutdown on linux When sleep is not possible
Memo on Mac OS X
Using multiple versions of Python on Mac OS X (2) Usage
Build a python data analysis environment on Mac (El Capitan)
I installed Caffe so that I can do deep learning on MAC OS X El Capitan
Note: When Python is run on ImageJ Fiji, java.lang.IllegalArgumentException appears and its solution (mac OS)
Get started with the Python framework Django on Mac OS X
Using multiple versions of Python on Mac OS X (1) Multiple Ver installation
Install Sphinx on Mac OS X
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Install mitmproxy on Mac OS X
Solution when HDMI audio output is not possible on Ubuntu 20.04.1 LTS
Install lp_solve on Mac OS X and call it with python.
Build Python environment on Ubuntu (when pip is not the default)
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Install pgmagick on Mac OS X 10.9
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
python note: when easy_install is not available
Installed aws-cli On Mac OS X Lion
How to erase Python 2.x on Mac.
Notes on building Python and pyenv on Mac
Run NASA CEA on Mac OS X
I installed Pygame with Python 3.5.1 in the environment of pyenv on OS X
Separately install a version of Python that is not pre-installed on your Mac
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Steps to use the AWS command line interface (Python / awscli) on Mac OS X
python on mac
Preparing to use aws cli on Mac OS X
Building an environment for "Tello_Video" on Mac OS X
Build a machine learning Python environment on Mac OS
Very easy to install SciPy on Mac OS X
Try using E-Cell 4 on Windows 7 or Mac OS X
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Build a Python environment on your Mac using pyenv
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
Install Python environment on local PC (pyenv, venv on Mac)
Create a Python development environment on OS X Lion
pangolin x python x mac os build failed memorandum unsolved
Minimum notes when using Python on Mac (Homebrew edition)
I learned MNIST with Caffe and tried to draw it (MAC OS X El Capitan)
Steps to install the latest version of OpenCV on OS X El Capitan without Homebrew
A memorandum (masOS) that import tkinter could not be done with python installed from pyenv