You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# VERY IMPORTANT!!!
env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" pyenv install 3.7.0
Set local python version, create & activate virtual environment
pyenv local 3.7.0
# ONLY `venv`, DO NOT USE `virtualenv`.
python -m venv .venv
source .venv/bin/activate
If you do not install python with env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" or not create virtual environment with python -m venv :
ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
Install matplotlib
pip install -U pip matplotlib
you can now work with matplotlib happily ! 🎊
TODO
tkinter's problem
python -m tkinter -c 'tkinter._test()'
Traceback (most recent call last):
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/tkinter/__main__.py", line 7, in<module>main()
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 3985, in _test
root = Tk()
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2022, in __init__
self._loadtk()
File "/Users/songjian/.pyenv/versions/3.7.0/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2037, in _loadtk
% (_tkinter.TK_VERSION, tk_version))
RuntimeError: tk.h version (8.6) doesn't match libtk.a version (8.5)
Having this as well. Just changed the default backend in matplotlibrc but would like to understand how to fix this without doing that.
looking into this further, for me the python installed by brew (/usr/local/bin/python3) with pip install matplotlib seems to work with tkinter._test().
pyenv + matplotlib
macOS 10.14
,Homebrew 1.8.0
,pyenv 1.2.7
Step by Step
Install tcl-tk before pyenv install
Install Python (e.g. 3.7.0) with pyenv
Set local python version, create & activate virtual environment
If you do not install python with
env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang"
or not create virtual environment withpython -m venv
:ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
Install matplotlib
you can now work with
matplotlib
happily ! 🎊TODO
tkinter's problem
References
Working with Matplotlib on OSX
Matplotlib Installation
pyenv virtualenv not work for matplotlib #issuecomment-418515459
The text was updated successfully, but these errors were encountered: