Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyenv + matplotlib #15

Open
jiansoung opened this issue Oct 29, 2018 · 3 comments
Open

pyenv + matplotlib #15

jiansoung opened this issue Oct 29, 2018 · 3 comments

Comments

@jiansoung
Copy link
Owner

pyenv + matplotlib

macOS 10.14, Homebrew 1.8.0, pyenv 1.2.7

Step by Step

Install tcl-tk before pyenv install

brew install tcl-tk

Install Python (e.g. 3.7.0) with pyenv

# 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)

References

@cdbattags
Copy link

cdbattags commented May 21, 2019

you figure out a workaround for this?

@jidicula
Copy link

I'm running into this issue too, but with pyenv-installed 3.5.3.

@grahamannett
Copy link

grahamannett commented Jul 18, 2019

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants