PyPlot broken under 1.7?

Pkg.add shows errors in PyCall and PyPlot, requesting precompiling.
Pkg.precompile throws errors and requests Pkg.build(“PyCall”)
This then throws the erros below.

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_EDITOR = code.cmd
  JULIA_NUM_THREADS =
[ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
ERROR: LoadError: PyCall not properly installed. Please run Pkg.build("PyCall")
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] top-level scope
    @ C:\Users\bardo\.julia\packages\PyCall\3fwVL\src\startup.jl:44
  [3] include(mod::Module, _path::String)
    @ Base .\Base.jl:418
  [4] include(x::String)
    @ PyCall C:\Users\bardo\.julia\packages\PyCall\3fwVL\src\PyCall.jl:1
  [5] top-level scope
    @ C:\Users\bardo\.julia\packages\PyCall\3fwVL\src\PyCall.jl:38
  [6] include
    @ .\Base.jl:418 [inlined]
  [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1318
  [8] top-level scope
    @ none:1
  [9] eval
    @ .\boot.jl:373 [inlined]
 [10] eval(x::Expr)
    @ Base.MainInclude .\client.jl:453
 [11] top-level scope
    @ none:1
in expression starting at C:\Users\bardo\.julia\packages\PyCall\3fwVL\src\startup.jl:41
in expression starting at C:\Users\bardo\.julia\packages\PyCall\3fwVL\src\PyCall.jl:1
ERROR: LoadError: Failed to precompile PyCall [438e738f-606a-5dbb-bf0a-cddfbfd45ab0] to C:\Users\bardo\.julia\compiled\v1.7\PyCall\jl_D7B3.tmp.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] include
    @ .\Base.jl:418 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1318
  [9] top-level scope
    @ none:1
 [10] eval
    @ .\boot.jl:373 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude .\client.jl:453
 [12] top-level scope
    @ none:1
in expression starting at C:\Users\bardo\.julia\packages\PyPlot\XaELc\src\PyPlot.jl:2
ERROR: LoadError: Failed to precompile PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] to C:\Users\bardo\.julia\compiled\v1.7\PyPlot\jl_D64C.tmp.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] eval
    @ .\boot.jl:373 [inlined]
  [8] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:1196
  [9] include_string(m::Module, txt::String, fname::String)
    @ Base .\loading.jl:1206
 [10] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\essentials.jl:716
 [11] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base .\essentials.jl:714
 [12] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:238
 [13] (::VSCodeServer.var"#60#64"{Bool, Bool, Module, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:182
 [14] withpath(f::VSCodeServer.var"#60#64"{Bool, Bool, Module, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\repl.jl:185
 [15] (::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:180
 [16] hideprompt(f::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\repl.jl:36
 [17] (::VSCodeServer.var"#58#62"{Bool, Bool, Bool, Module, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:151
 [18] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:511
 [19] with_logger
    @ .\logging.jl:623 [inlined]
 [20] (::VSCodeServer.var"#57#61"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:228
 [21] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [22] invokelatest(::Any)
    @ Base .\essentials.jl:714
 [23] macro expansion
    @ c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
 [24] (::VSCodeServer.var"#55#56")()
    @ VSCodeServer .\task.jl:423
in expression starting at g:\Andere Computer\Work\Shared\Julia\timestepping.jl:54

julia> Pkg.build("PyCall")
ERROR: UndefVarError: Pkg not defined
Stacktrace:
 [1] top-level scope


julia> Pkg.build("PyCall")
    Building Conda ─→ `C:\Users\bardo\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\6cdc8832ba11c7695f494c9d9a1c31e90959ce0f\build.log`
    Building PyCall → `C:\Users\bardo\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\4ba3651d33ef76e24fef6a598b63ffd1c5e1cd17\build.log`
ERROR: Error building `PyCall`: 
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(143): Could not remove or rename C:\Users\bardo\.julia\conda\3\pkgs\mkl-2021.4.0-h0e2418a_729.tar.bz2.  Please remove this file manually (you may need to reboot to free file handles)

## Package Plan ##

  environment location: C:\Users\bardo\.julia\conda\3

  added / updated specs:
    - numpy


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    mkl-2021.4.0               |     h0e2418a_729       181.7 MB  conda-forge
    ------------------------------------------------------------
                                           Total:       181.7 MB

The following NEW packages will be INSTALLED:

  intel-openmp       conda-forge/win-64::intel-openmp-2021.4.0-h57928b3_3556
  libblas            conda-forge/win-64::libblas-3.9.0-12_win64_mkl
  libcblas           conda-forge/win-64::libcblas-3.9.0-12_win64_mkl
  liblapack          conda-forge/win-64::liblapack-3.9.0-12_win64_mkl
  mkl                conda-forge/win-64::mkl-2021.4.0-h0e2418a_729
  numpy              conda-forge/win-64::numpy-1.21.4-py39h6635163_0
  tbb                conda-forge/win-64::tbb-2021.4.0-h2d74725_1



Downloading and Extracting Packages
mkl-2021.4.0         | 181.7 MB  | #########9 | 100% WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(143): Could not remove or rename C:\Users\bardo\.julia\conda\3\pkgs\mkl-2021.4.0-h0e2418a_729\Library\bin\mkl_avx2.1.dll.  Please remove this file manually (you may need to reboot to free file handles)WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(143): Could not remove or rename C:\Users\bardo\.julia\conda\3\pkgs\mkl-2021.4.0-h0e2418a_729\Library\bin\mkl_avx2.1.dll.  Please remove this file manually (you may need to reboot to free file handles)
mkl-2021.4.0         | 181.7 MB  | ########## | 100%
TypeError('not all arguments converted during string formatting')


┌ Info: Using the Python distribution in the Conda package by default.
└ To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").   
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: failed process: Process(setenv(`'C:\Users\bardo\.julia\conda\3\Scripts\conda.exe' install -y numpy`,["PATH=C:\\Users\\bardo\\.julia\\conda\\3\\Library\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\MATLAB\\R2019b\\bin;C:\\Ch\\bin;C:\\MinGW\\bin;C:\\Program Files\\CMake\\bin;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\LLVM\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\bardo\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\\;C:\\Users\\bardo\\AppData\\Local\\Programs\\Python\\Python38\\;C:\\Users\\bardo\\AppData\\Local\\Microsoft\\WindowsApps;C:\\MinGW\\bin;C:\\Users\\bardo\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Exercism;C:\\Users\\bardo\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\bardo\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64\\;C:\\Users\\bardo\\AppData\\Local\\Pandoc\\", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-C4BJHNV", "HOMEPATH=\\Users\\bardo", "JD2_HOME=C:\\Users\\bardo\\AppData\\Local\\JDownloader 2.0", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CH", "SESSIONNAME=Console", "SYSTEMROOT=C:\\WINDOWS", "APPDATA=C:\\Users\\bardo\\AppData\\Roaming", "PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files"  …  "CHROME_CRASHPAD_PIPE_NAME=\\\\.\\pipe\\crashpad_17204_VIOIXDGUCCUMHVEZ", "LOGONSERVER=\\\\DESKTOP-C4BJHNV", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "ORIGINAL_XDG_CURRENT_DESKTOP=undefined", "POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows 10 Pro", "CONDA_PREFIX=C:\\Users\\bardo\\.julia\\conda\\3", "JULIA_LOAD_PATH=@;C:\\Users\\bardo\\AppData\\Local\\Temp\\jl_JHintj", "SYSTEMDRIVE=C:", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1"]), ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ .\process.jl:531 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:446
 [3] run
   @ .\process.jl:444 [inlined]
 [4] runconda(args::Cmd, env::String)
   @ Conda C:\Users\bardo\.julia\packages\Conda\1403Y\src\Conda.jl:130
 [5] add(pkg::String, env::String; channel::String)
   @ Conda C:\Users\bardo\.julia\packages\Conda\1403Y\src\Conda.jl:223
 [6] add (repeats 2 times)
   @ C:\Users\bardo\.julia\packages\Conda\1403Y\src\Conda.jl:222 [inlined]
 [7] top-level scope
   @ C:\Users\bardo\.julia\packages\PyCall\3fwVL\deps\build.jl:79
 [8] include(fname::String)
   @ Base.MainInclude .\client.jl:451
 [9] top-level scope
   @ none:5
in expression starting at C:\Users\bardo\.julia\packages\PyCall\3fwVL\deps\build.jl:43
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Types.jl:68
  [2] (::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:962
  [3] withenv(::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String}})
    @ Base .\env.jl:172
  [4] (::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1506
  [5] with_temp_env(fn::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)       
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1390
  [6] (::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1469
  [7] mktempdir(fn::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem .\file.jl:750
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem .\file.jl:748
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; force_latest_compatible_version::Bool, 
allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1435
 [10] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:1432
 [11] build_versions(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}; verbose::Bool)
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:943
 [12] build(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}, verbose::Bool)
    @ Pkg.Operations C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\Operations.jl:822
 [13] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:992
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:149
 [15] build(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:144
 [16] #build#99
    @ C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:142 [inlined]
 [17] build
    @ C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:142 [inlined]
 [18] #build#98
    @ C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:141 [inlined]
 [19] build(pkg::String)
    @ Pkg.API C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Pkg\src\API.jl:141
 [20] top-level scope
    @ REPL[3]:1

julia> 

There is an error (in Python) during your Anaconda / Miniforge installation (via Conda.jl). You might try deleting ~/.julia/conda and trying again.

(You could also install Python and matplotlib manually and configure PyCall to use that.)

Thanks Steven for having a deep look into the error messages.

Removed conda, but now Julia hangs on using PyPlot or Pkg.build(“PyCall”).
Starting fresh, I get

ERROR: LoadError: IOError: connect: no such file or directory (ENOENT)
Stacktrace:
 [1] wait_connected(x::Base.PipeEndpoint)
   @ Sockets C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\Sockets.jl:532
 [2] connect
   @ C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\Sockets.jl:567 [inlined] [3] connect
   @ C:\Users\bardo\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\PipeServer.jl:97 [inlined]
 [4] serve(args::String; is_dev::Bool, crashreporting_pipename::String)
   @ VSCodeServer c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\packages\VSCodeServer\src\VSCodeServer.jl:100
 [5] top-level scope
   @ c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\terminalserver\terminalserver.jl:45
in expression starting at c:\Users\bardo\.vscode\extensions\julialang.language-julia-insider-1.5.6\scripts\terminalserver\terminalserver.jl:24
julia> 

PyPlot works for me in 1.7.0, so it’s at least not broken (on Linux). I’m not sure what your issue is, but you can of course try another (non-Python-based) plotting library (Makie?), or since your problem seems to be with PyCall, rather than strictly PyPlot, you may want to look into the competitor PythonCall.jl. It downloads Python for your, and seems to have some MatPlotLib support (the same library PyPlot uses): Compatibility Tools · PythonCall & JuliaCall

The package has at least two ways to add packages, with conda (mamba coming later, as drop-in replacement), or I thought with pip this way (seems may have used conda…):

julia> PythonCall.Deps.add(pip_packages=["matplotlib"])
[..]
[ Info: You will need to restart Julia if this Conda command reinstalled Python or any other packages.

so I did. And then I got the example there working (just trivially modified):
https://matplotlib.org/stable/tutorials/introductory/pyplot.html

julia> @py import matplotlib.pyplot as plt
julia> @py plt.plot([1, 2, 3, 4])
Python list: [<matplotlib.lines.Line2D object at 0x7ff5a0576830>]

julia> @py plt.ylabel('some numbers')
ERROR: syntax: character literal contains multiple characters
Stacktrace:
 [1] top-level scope
   @ none:1

julia> @py plt.ylabel("some numbers")
Python Text: Text(0, 0.5, 'some numbers')

julia> @py plt.show()
1 Like

Thanks for the tip with PythonCall!
This worked:

(@v1.7) pkg> rm PyCall
(@v1.7) pkg> add PythonCall
using PyPlot  #  ​installing a lot of packages -> ok

Now, I could even add PyCall again, did not ask for precompiling or rebuilding.

1 Like

You marked my comment above as the “solution”. I would just like to clarify adding PythonCall didn’t do anything for you, or shouldn’t have, so I do not want to take credit for that.

Your rm PyCall did something, and even if you do not see it in with (@v1.7) pkg> st i.e. it no longer there in the Projects.toml file, it’s there in ~/.julia/environments/v1.7/Manifest.toml because PyPlot depends on it.

If you want to credit me with “fixing”, by accident, then rather point to this post to not confuse others.

EDIT: I wrote adding PythonCall didn’t do anything, but one possibility is it forced an upgrade for Conda.jl. It depends on version 1.5, while PyCall only depends on 1.0. I’m not sure what caused your fix but it’s a likely candidate, and looking at Conda I saw:
https://github.com/JuliaPy/Conda.jl/issues/138

If Conda had anything to do with this, you could have gotten the same effect by only upgrading it (and you should be able to rm PythonCall), and then maybe PyCall should add as strict a Conda requirement.

Yes, it certainly sounds like the problem stemmed from the Python installation itself (via Conda), and not with PyCall or PythonCall themselves.

You realize that just removing the Conda.jl package won’t remove the corresponding Python installation? (Re-installing PyCall will re-install Conda.jl, and it will still use the previous Python install.)

1 Like

That was a ] rm Conda.
You certainly have a better understanding of the mechanisms behind.
All I can say is, a ] rm PyCall, add PythonCall` “fixed” it.
I relocated the solution flag accordingly.

I tried many methods and found the following works:

julia > ENV[“PYTHON”]=“python3”

] add PyCall, PyPlot
] build PyCall
] build PyPlot