简体   繁体   English

安装julia后pyplot错误

[英]pyplot error after installing julia

Installed julia v0.3.2 into MacOSX 10.9.5 Did 在MacOSX 10.9.5中安装了julia v0.3.2

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. 这将启动一个IJulia笔记本(它在左上角显示IJ。

I enter using pyplot into the first line of iJulia, hit shift enter, and get this: 我使用pyplot输入iJulia的第一行,按shift键输入,并得到以下信息:

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. objc [21233]:在/Library/Frameworks/Tk.framework/Versions/8.5/Tk和/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk中都实现了TKApplication类。 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. objc [21233]:在/Library/Frameworks/Tk.framework/Versions/8.5/Tk和/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk中都实现了TKMenu类。 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. objc [21233]:TKContentView类在/Library/Frameworks/Tk.framework/Versions/8.5/Tk和/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. objc [21233]:在/Library/Frameworks/Tk.framework/Versions/8.5/Tk和/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk中都实现了TKWindow类。 One of the two will be used. 将使用两者之一。 Which one is undefined. 哪一个未定义。 INFO: Loading help data... Warning: requiring "pyplot" did not define a corresponding module. 信息:正在加载帮助数据...警告:要求“ pyplot”未定义相应的模块。

OK, so my mac has the tk package installed in two places. 好的,所以我的Mac在两个地方都安装了tk软件包。 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: 如果我从Library / Frameworks中删除了TK和TCL框架,请按照此处的建议进行操作: http : //michaelwelburn.com/2013/06/07/python-error-conflicting-tk-libraries-and-activetcl/和此处: Python tk框架,然后在尝试启动iJulia时出现以下错误:

INFO: Loading help data... Warning: requiring "pyplot" did not define a corresponding module. 信息:正在加载帮助数据...警告:要求“ pyplot”未定义相应的模块。

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 我的/ usr / local / bin目录包括以下可执行文件: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. 我有本地mac python和anaconda版本(具有自己的lib / tk),我对下一步不知所措。

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: 每行都可以在iJulia中正常执行,但最后一行以imshow开头会出现此错误:

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 我的问题是.bash_profile我有这些行

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

leftover from a previous python install. 以前的python安装的剩余部分。 I also had a bunch of executables in my /usr/local/bin folder from this old python install. 在这个旧的python安装中,我的/ usr / local / bin文件夹中也有很多可执行文件。 When I deleted the python 2.7 folder before putting in anaconda, I forgot to delete these. 当我在放入anaconda之前删除python 2.7文件夹时,我忘了删除它们。

Now the error is gone. 现在错误消失了。 I hope this helps someone. 我希望这可以帮助别人。

For the Warning: Warning: requiring "*" did not define a corresponding module. 对于警告: 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. 使用0.38+的旧版本遇到同样的问题。 After switching back to 0.37 stable the issue was gone. 切换回0.37稳定后,问题消失了。

Run into this issue with PyCall: Warning: requiring "PyCall" did not define a corresponding module. PyCall遇到此问题: Warning: requiring "PyCall" did not define a corresponding module.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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