-
Notifications
You must be signed in to change notification settings - Fork 189
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
Matplotlib Python is not installed as a framework... #218
Comments
@randy3k, you wrote the initial note about framework installs in #122, do you have any ideas? @xanderdunn, in the meantime you could just use the Anaconda matplotlib via the Conda.jl package, via (in a fresh Julia session): ENV["PYTHON"]=""
Pkg.build("PyCall")
using PyPlot which will download and install the Anaconda Matplotlib in a private Julia directory. |
I don't have any idea. |
Thanks to both of you for looking at this. Yes, I noticed that the error messages being spit out were always referencing the same matplotlib.py file on disk, regardless of which Python installation PyCall was using. I figured out this is because I had the system's pip package directory in my PYTHONPATH! 😫 So, regardless of the Python being used, it always found that matplotlib installation first. With that all cleared out of my PYTHONPATH, the Conda.jl method that @stevengj mentioned above works. On first try, system Python and Pyenv were still giving the same error, but I need to methodically step through them again. |
Yeah, I still get the error:
It's correctly referring to the matplotlib installed via the pyenv 2.7.10's pip. I uninstalled the pyenv's 2.7.10 installation and reinstalled it with Same with uninstalling brew's python 2 and reinstalling it with |
I have tested your code with pyenv 2.7.6, 2.7.10 and 3.4.3. They all work fine. julia> loadlocalpython("test.py")
Loading Python module test.py
PyObject <module 'test' from 'test.pc'> with |
Wait, I can actually reproduce the error if import matplotlib.pyplot In fact, the error should be reproduced in Julia by running @pyimport matplotlib.pyplot as plt I found a solution. It is because python within Julia fails to find a backend. The following will fix it:
|
@randy3k Oh, wow! Thank you so much! This solved it! |
I guess using PyCall
using PyPlot
loadlocalpython("test.py") |
PyPlot is a bit smarter about picking a backend than if you do a raw |
Problem Cause In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). Set the back end of macosx that is differ compare with other windows or linux os. I resolve this issue following ways:
|
@randy3k Thank you ! |
@aysebilgegunduz Thank you! |
@aysebilgegunduz super helpful. Totally made my day! |
@randy3k Yeah! Worked for me too! Thank you ;) |
it works, but would be nice to know why it works |
What is that file? Use TextEdit to crate a new file? And just add the line to the file? |
Hey! I could not solve my problem with this issue? Could you make it more explicit? |
The full error I get at runtime:
I'm on Mac OSX 10.11. I've tried a number of things:
I've installed python with
brew install python --framework
I've tried
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 2.7.10
I've tried creating the script shown at the bottom of this Matplotlib FAQ page and then setting it:
After each of these, I made sure the Python I had just installed/configured was selected and I ran
rm(Pkg.dir("PyCall","deps","PYTHON")); Pkg.build("PyCall")
. I always get the same error.No matter what I try, I'm unable to import a local Python file that imports matplotlib.
Note that I'm not calling
@pyimport matplotlib
in a Julia file, I'm importing an existing Python file that has its ownimport matplotlib as plt
statement. I'm loading the local file with this function:Running the same python file from the command line
python myfile.py
, of course works fine.The text was updated successfully, but these errors were encountered: