JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
475 stars 87 forks source link

Mac M1, no gui #542

Open francescoalemanno opened 2 years ago

francescoalemanno commented 2 years ago
192 ~ % julia              
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0 (2021-11-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using PyPlot
[ Info: Installing pyqt package to avoid buggy tkagg backend.
[ Info: Installing PyQt5 via the Conda pyqt package...
[ Info: Running `conda install -y pyqt` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - pyqt

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)

Any known workarounds?

EthanAnderes commented 2 years ago

I had the same problem. Was playing around with it the other day and came up with something seems to work for the time being. Just thought I would post it here for reference.

using PyCall    
pygui(:tk)
using PyPlot

... or add the following line to ~/.matplotlib/matplotlibrc

backend : TkAgg

Note: I get a warning about Tk being buggy but I haven't run into any problems yet.

julia> versioninfo()
Julia Version 1.8.0-DEV.1268
Commit 955d427135 (2022-01-10 15:37 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.0 (ORCJIT, cyclone)
Environment:
  JULIA_NUM_THREADS = 5
damonturney commented 2 years ago

Yes I have the same problem on my new macbook pro.

I was able to get pyqt working with PyPlots by installing pyqt via a special Conda channel:

Conda.add("pyqt", channel="andfoy")

Also it seems that conda channel robostack-experimental has pyqt for arm64.... just wish I knew which channel was better or that I trusted these rare "one off" channels.

Why hasn't Conda-forge added arm64 version of pyqt?

stevengj commented 2 years ago

Works fine for me on M1; maybe this was a recent problem with Conda?

You can always try a different backend, e.g. set ENV["MPLBACKEND"]="tkagg" before loading PyPlot.

damonturney commented 2 years ago

Steve how did you install PyQt5? With Julia and PyPlots, the default conda channels don't even have a working version of pyqt for arm64 chips.... so maybe you had added other conda channels or installed PyQt5 via other methods beyond the Julia Conda package manager?

stevengj commented 2 years ago

I just let Conda install it with the default installer, I didn't do anything special:

julia> Conda.list()
[ Info: Running `conda list` in root environment
# packages in environment at /Users/stevenj/.julia/conda/3:
#
# Name                    Version                   Build  Channel
adwaita-icon-theme        40.1.1               hca03da5_1  
appnope                   0.1.2           py38hca03da5_1001  
argon2-cffi               20.1.0           py38h1a28f6b_2  
...
pyqt                      5.15.2           py38he8f2410_0  
pyqt5-sip                 4.19.25                  pypi_0    pypi
pyqtchart                 5.15.2                   pypi_0    pypi
...

I'm just using the default channels:

julia> run(Conda._set_conda_env(`$(Conda.conda) config --show channels`))
channels:
  - defaults
damonturney commented 2 years ago

Ok, but we all need to see which conda channel your pyqt came from. pyqt doesn't seem to be available with the normal conda channels.

GenevieveBuckley commented 2 years ago

PyQt for M1 macs is now available from conda-forge (and also from the andfoy channel, which is what I was using earlier this year before the conda-forge build became available)

conda install pyqt -c conda-forge

Perhaps this means this issue can now be closed?