简体   繁体   中英

pyplot error after installing julia

Installed julia v0.3.2 into MacOSX 10.9.5 Did

Pkg.add("IJulia")
Pkg.add("PyPlot")

initiate ijulia with:

ipython notebook --profile=julia

This starts an IJulia notebook (it says IJ in the top left.

I enter using pyplot into the first line of iJulia, hit shift enter, and get this:

objc[21233]: Class TKApplication is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[21233]: Class TKMenu is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[21233]: Class TKContentView is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. objc[21233]: Class TKWindow is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined. INFO: Loading help data... Warning: requiring "pyplot" did not define a corresponding module.

OK, so my mac has the tk package installed in two places. If i remove the TK and TCL frameworks from Library/Frameworks, as suggested here: http://michaelwelburn.com/2013/06/07/python-error-conflicting-tk-libraries-and-activetcl/ and here: Python tk framework then I get the following error when I try to start iJulia:

INFO: Loading help data... Warning: requiring "pyplot" did not define a corresponding module.

The other authors said this worked so I am confused.

My /usr/local/bin directory includes these) executables: tclselect tclsh tclsh8.5 tclsh8.6 tclvfse wish wish8.5 wish8.6

I hesitate to remove the system framework. I have the native mac python as well as the anaconda version (which has its own lib/tk) I am at a loss as to the next step.

EDIT: My julia code is this:

using PyPlot

# julia set
# (the familiar mandelbrot set is obtained by setting c==z initially)
function julia(z, c; maxiter=200)
    for n = 1:maxiter
        if abs2(z) > 4
            return n-1
        end
        z = z*z + c
    end
    return maxiter
end

# varying the second argument to julia() tiny amounts results in a stunning variety of forms
@time m = [ uint8(julia(complex(r,i), complex(-.06,.67))) for i=1:-.002:-1, r=-1.5:.002:1.5 ];

# the notebook is able to display ColorMaps
get_cmap("RdGy")

imshow(m, cmap="RdGy", extent=[-1.5,1.5,-1,1])

each line executes fine in iJulia except the last line starting with imshow which gives this error:

PyError (PyObject_Call) <class '_tkinter.TclError'>
TclError('Can\'t find a usable tk.tcl in the following directories: \n    /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts\n\n/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl: version conflict for package "Tk": have 8.5.15, need exactly 8.5.9\nversion conflict for package "Tk": have 8.5.15, need exactly 8.5.9\n    while executing\n"package require -exact Tk  8.5.9"\n    (file "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl" line 20)\n    invoked from within\n"source /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl"\n    ("uplevel" body line 1)\n    invoked from within\n"uplevel #0 [list source $file]"\n\n\nThis probably means that tk wasn\'t installed properly.\n',)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2370, in imshow
    ax = gca()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 701, in gca
    ax =  gcf().gca(**kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 343, in figure
    **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
    window = Tk.Tk()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1764, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)

while loading In[7], in expression starting on line 1

 in pyerr_check at /Users/userme/.julia/v0.3/PyCall/src/exception.jl:58
 in pycall at /Users/userme/.julia/v0.3/PyCall/src/PyCall.jl:85
 in imshow at /Users/userme/.julia/v0.3/PyPlot/src/PyPlot.jl:370

I feel so stupid. My problem was the .bash_profile I had these lines

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

leftover from a previous python install. I also had a bunch of executables in my /usr/local/bin folder from this old python install. When I deleted the python 2.7 folder before putting in anaconda, I forgot to delete these.

Now the error is gone. I hope this helps someone.

For the Warning: Warning: requiring "*" did not define a corresponding module. In some cases it helps to check if we use a stable version.

Ran into same issues with 0.38+pre-versions. After switching back to 0.37 stable the issue was gone.

Run into this issue with PyCall: Warning: requiring "PyCall" did not define a corresponding module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM