PyCall.PyError
- Langage dominant
- Julia
- Étoiles
- 1.5k
- Forks
- 186
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hello, I try to use PyCall but I have the same error every times. I use Julia 1.4 with Atom (Juno). Here one of the code I try to use :
`ENV["PYTHON"] = ""
#Pkg.update()
#Pkg.build("PyCall")
using LaTeXStrings
using PyPlot
using DelimitedFiles
rc("text",usetex="True")
rc("font",family="serif",size=20)
npoints = 100;
x = range(0; stop=2*pi, length=npoints)
function f(x)
return sin(3 * x^0.5) / (2 + cos(2 * x))
end
y = f.(x);
cd("/Users/adrienwafflard/Documents/ULg/OQ/julia")
open("out.txt", "w") do io
writedlm(io, [x y])
end
figure(figsize=(8,6));
plot(x, y, color="red", linewidth=2.0, linestyle="--")
xlabel(L"$x$")
ylabel(L"$y(x)$")
title(L"Graph of $y(x)=\sin\left(\frac{3\sqrt{x}}{2+\cos(2x)}\right)$")
text(0.9, 0.32, "Max")
tight_layout()
cd("/mydir")
savefig("./plot.pdf")
close()
rc("font",family="serif",size=12)
figarr, axarr = subplots(2, 2)
figarr.suptitle("Many plots")
figarr.subplots_adjust(hspace=0.5, wspace=0.5)
axarr[1, 1].plot(x, y)
# preserve aspect ratio for linear-linear plots
axarr[1, 1].axis("equal")
axarr[1, 1].set(title="Plot [1,1]", xlabel=L"$x$")
axarr[1, 2].scatter(x, y)
axarr[1, 2].set_title("Plot [1,2]")
axarr[1, 2].set(ylabel=L"$y$")
axarr[2, 1].plot(x, y, color="#663300")
axarr[2, 1].set_title("Plot [2,1]")
# Hide x labels and tick labels
axarr[2, 1].label_outer()
axarr[2, 2].scatter(x, y, color="#663300", alpha=0.2)
axarr[2, 2].set_title("Plot [2,2]")
tight_layout()
savefig("./panels.pdf")
close("all")`
and the error:
`LoadError: PyCall.PyError("\$(Expr(:escape, :(ccall(#= /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (Py
Ptr, PyPtr, PyPtr), o, pyargsptr, kw))))", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00000001481b6408), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000015f2b5cb0), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000015f2eb9b0))
Stacktrace:
[1] pyerr_check at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/exception.jl:60 [inlined]
[2] pyerr_check at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/exception.jl:64 [inlined]
[3] _handle_error(::String) at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/exception.jl:81
[4] macro expansion at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/exception.jl:95 [inlined]
[5] #110 at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:43 [inlined]
[6] disable_sigint at ./c.jl:446 [inlined]
[7] __pycall! at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:42 [inlined]
[8] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{}, ::Int64, ::Ptr{Nothing}) at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:29
[9] _pycall! at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:11 [inlined]
[10] #pycall#116 at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:83 [inlined]
[11] pycall at /Users/adrienwafflard/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:83 [inlined]
[12] tight_layout(; kws::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/adrienwafflard/.julia/packages/PyPlot/4wzW1/src/PyPlot.jl:177
[13] tight_layout() at /Users/adrienwafflard/.julia/packages/PyPlot/4wzW1/src/PyPlot.jl:174
[14] top-level scope at /Users/adrienwafflard/Downloads/Plot_scripts_example.jl:33
in expression starting at /Users/adrienwafflard/Downloads/Plot_scripts_example.jl:33`
I tried other examples but I have the same error.
I also have Python 3.3.7. I use macOS X 15.4 but I have the same problem on my PC (windows 10). Finally I have those packages installed :
`(@v1.4) pkg> status
Status `~/.julia/environments/v1.4/Project.toml`
[c52e3926] Atom v0.12.10
[8f4d0f93] Conda v1.4.1
[e5e0dc1b] Juno v0.8.1
[b964fa9f] LaTeXStrings v1.1.0
[91a5bcdd] Plots v0.29.9
[438e738f] PyCall v1.91.4
[d330b81b] PyPlot v2.8.2
[6e0679c1] QuantumOptics v0.7.1
[8bb1440f] DelimitedFiles`
Thank you for your help.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Reproduce the provided plotting script with the listed Julia, Python, PyCall, and PyPlot versions. Start at PyPlot.jl:174-177, then follow the stack trace through PyCall/src/exception.jl:60-95 and pyfncall.jl:29-43; done means the failure cause and affected configuration are identified.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- julia, python
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100