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

PyError #780

Closed
azev77 opened this issue May 18, 2020 · 1 comment
Closed

PyError #780

azev77 opened this issue May 18, 2020 · 1 comment

Comments

@azev77
Copy link

azev77 commented May 18, 2020

Stanford teaches intro to ML w/ Julia: http://ee104.stanford.edu/lectures.html
The program: house.jl calls houseplots.jl breaks when plotting w/ message:

PyError ($(Expr(:escape, :(ccall(#= C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'FileNotFoundError'>
FileNotFoundError(2, 'No such file or directory')
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\pyplot.py", line 729, in savefig
    res = fig.savefig(*args, **kwargs)
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\figure.py", line 2180, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\backend_bases.py", line 2091, in print_figure
    **kwargs)
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2496, in print_pdf
    file = PdfFile(filename, metadata=metadata)
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\backends\backend_pdf.py", line 432, in __init__
    fh, opened = cbook.to_filehandle(filename, "wb", return_opened=True)
  File "C:\Users\azevelev\.julia\conda\3\lib\site-packages\matplotlib\cbook\__init__.py", line 432, in to_filehandle
    fh = open(fname, flag, encoding=encoding)


Stacktrace:
 [1] pyerr_check at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\exception.jl:60 [inlined]
 [2] pyerr_check at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\exception.jl:64 [inlined]
 [3] _handle_error(::String) at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\exception.jl:81
 [4] macro expansion at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\exception.jl:95 [inlined]
 [5] #110 at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:43 [inlined]
 [6] disable_sigint at .\c.jl:446 [inlined]
 [7] __pycall! at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:42 [inlined]
 [8] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{String}, ::Int64, ::Ptr{Nothing}) at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:29
 [9] _pycall! at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:11 [inlined]
 [10] #pycall#116 at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:83 [inlined]
 [11] pycall at C:\Users\azevelev\.julia\packages\PyCall\zqDXB\src\pyfncall.jl:83 [inlined]
 [12] savefig(::String; kws::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\azevelev\.julia\packages\PyPlot\XHEG0\src\PyPlot.jl:177
 [13] savefig at C:\Users\azevelev\.julia\packages\PyPlot\XHEG0\src\PyPlot.jl:174 [inlined]
 [14] save at C:\Users\azevelev\Dropbox\COMPUTATION\_QE_Moll\ML\Stanford\houseplots.jl:23 [inlined]
 [15] plotregpath(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::String) at C:\Users\azevelev\Dropbox\COMPUTATION\_QE_Moll\ML\Stanford\houseplots.jl:40
 [16] plotridge(::Array{Array{Float64,2},1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::String) at C:\Users\azevelev\Dropbox\COMPUTATION\_QE_Moll\ML\Stanford\houseplots.jl:29
 [17] houseplots(::Array{String,2}, ::Array{String,1}, ::Array{Array{Float64,2},1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,2}) at C:\Users\azevelev\Dropbox\COMPUTATION\_QE_Moll\ML\Stanford\houseplots.jl:80
 [18] main() at .\In[8]:25
 [19] macro expansion at .\util.jl:175 [inlined]
 [20] top-level scope at .\In[8]:28
@stevengj
Copy link
Member

stevengj commented May 19, 2020

"No such file or directory" is being thrown by a savefig call, according to the traceback. Maybe you are trying to save to a directory that doesn't exist?

In particular, it looks like houseplots.jl calls plt.savefig(plotname(name)), but plotname(x) returns "graphics/$(fname)_$(basename2).$(extension)". So I'm guessing that the graphics directory doesn't exist; maybe you need to run mkpath("graphics")?

Anyway, this doesn't seem like a problem with PyCall per se. If you have usage questions or need help debugging your code, a better place to post is https://discourse.julialang.org/

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

No branches or pull requests

2 participants