OpenStreetMapXPlot.jl
OpenStreetMapXPlot.jl copied to clipboard
I can not install OpenStreetMapXPlot "ERROR: LoadError: InitError: PyError (PyImport_ImportModule"
Hello. I am here for asking help because I have a problem to install OpenStreetMapXPlot.
I am testing Agents.jl package. One of the examples they provide using OpenStreetmapXPlot.
However It can not be precompiled because of error below. According to the error message, it does not have proper version of "libfreetype.6.dylib" but I have installed the version 25.0.1 on my Mac.
I want to know how can I solve this problem.
[ Info: Precompiling OpenStreetMapXPlot [d3d4fdd0-c191-11e8-3358-a3629b56487d]
[ Info: Installing matplotlib via the Conda matplotlib package...
[ Info: Running `conda install -y matplotlib` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
ERROR: LoadError: InitError: PyError (PyImport_ImportModule
The Python package matplotlib could not be imported by pyimport. Usually this means
that you did not install matplotlib in the Python version being used by PyCall.
PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the matplotlib module, you can
use `pyimport_conda("matplotlib", PKG)`, where PKG is the Anaconda
package that contains the module matplotlib, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.
) <class 'ImportError'>
ImportError('dlopen(/Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so, 2): Library not loaded: @rpath/libfreetype.6.dylib\n Referenced from: /Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so\n Reason: Incompatible library version: ft2font.cpython-39-darwin.so requires version 25.0.0 or later, but libfreetype.6.dylib provides version 24.0.0')
File "/Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/__init__.py", line 208, in <module>
_check_versions()
File "/Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/__init__.py", line 193, in _check_versions
from . import ft2font
Stacktrace:
[1] pyimport(name::String)
@ PyCall ~/.julia/packages/PyCall/L0fLP/src/PyCall.jl:550
[2] pyimport_conda(modulename::String, condapkg::String, channel::String)
@ PyCall ~/.julia/packages/PyCall/L0fLP/src/PyCall.jl:714
[3] pyimport_conda
@ ~/.julia/packages/PyCall/L0fLP/src/PyCall.jl:707 [inlined]
[4] __init__()
@ PyPlot ~/.julia/packages/PyPlot/XaELc/src/init.jl:185
[5] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:674
[6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base ./loading.jl:760
[7] _require(pkg::Base.PkgId)
@ Base ./loading.jl:998
[8] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:914
[9] require(into::Module, mod::Symbol)
@ Base ./loading.jl:901
[10] include
@ ./Base.jl:386 [inlined]
[11] 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::Nothing)
@ Base ./loading.jl:1213
[12] top-level scope
@ none:1
[13] eval
@ ./boot.jl:360 [inlined]
[14] eval(x::Expr)
@ Base.MainInclude ./client.jl:446
[15] top-level scope
@ none:1
during initialization of module PyPlot
in expression starting at /Users/jundamin/.julia/packages/OpenStreetMapXPlot/YIKdT/src/OpenStreetMapXPlot.jl:1
I had the same problem yesterday. I’m running the latest official release of Julia. After several failed attempts at fixes, what finally worked was to delete the ~/.julia directory and re-add everything.
This looks like a problem installing PyPlot
which is a dependency of OpenStreetMapXPlot.
matplotlib
is a Python library that is being installed together with PyPlot
, perhaps the first time it is run.
What happens when you try doing:
ENV["PYTHON"]=""
using Pkg
pkg"add PyCall"
pkg"build PyCall"
pkg"add PyPlot"
pkg"build PyPlot"
using PyPlot
If the code above succeeds, there should be no problem with running OpenStreetMapXPlot. If you have still any problem please let me know.
@pszufe , I have do the process but still have same problem as below.
ImportError('dlopen(/Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so, 2): Library not loaded: @rpath/libfreetype.6.dylib\n Referenced from: /Users/jundamin/.julia/conda/3/lib/python3.9/site-packages/matplotlib/ft2font.cpython-39-darwin.so\n Reason: Incompatible library version: ft2font.cpython-39-darwin.so requires version 25.0.0 or later, but libfreetype.6.dylib provides version 24.0.0')
Now I try to remove julia and reinstall all.
I removed ~/.julia
and reinstall everything. And then it works.
This looks like a typical issue of "many Pythons share library paths". Similar error messages have been reported many times on StackOverflow.
One more useful step is adding ENV["PYTHON"]="
before executing pkg"build PyCall"
(I edited my answer)
Have also a look at similar issues: https://stackoverflow.com/questions/69968084/cannot-install-pycall-jl-with-julia-1-6-3-build-on-freebsd-13 https://stackoverflow.com/questions/64288845/julia-failure-to-configure-pycall-to-use-a-different-version https://stackoverflow.com/questions/55080497/julia-plots-pycall-pyerrorpyimport-importmodule-n-nthe-python-package-matplot https://stackoverflow.com/questions/48603958/julia-pyplot-not-working-conda-python-issues