I want to run “import geopandas” in julia1.6.0 in jupyter notebook. But there are some problems when I install this package. I use different methods to install it, and the erroe messages are showed in the following picture.
geopandas is a Python project, so it cannot be installed normally via Julia’s package manager (import Pkg; Pkg.add("geopandas")
or pkg> add geopandas
won’t work).
The Conda.add() function takes the package name as a string, so you could do the following:
using Pkg; Pkg.add("Conda")
using Conda
Conda.add("geopandas")
Thanks for your answer. There is still a error showed in the following picture after using your code. The Info suggests me to run “conda install -y geopandas” in root environment, but I don’t know where is the root environment, does it mean run “conda install -y geopandas” in Anaconda Prompt?
Seems like Conda couldn’t resolve the environment. Try again with CondaPkg and see if the problem reappears:
import Pkg; Pkg.add("CondaPkg")
using CondaPkg
CondaPkg.add("geopandas")
Thanks again for your reply. I’ll check it out whthere it is the problem of installation method.
@M-PERSIC I restart the jupyter notebook, and run the following code again:
using Pkg; Pkg.add("Conda")
using Conda
Conda.add("geopandas")
The error changed again. It said I already installed geopandas, but when I import geopandas, it said geopandas not found.
Besides, do you know how to resolve this error–AttributeError(“module ‘geopandas’ has no attribute ‘plotting’”)? It is showed in the following picture.
That’s good that Conda is working correctly now. I’ll think about filing an issue report if I can continue to reproduce the original error.
Again, geopandas is NOT a Julia package, you cannot interact with it like such. import geopandas
will not work. You need a Python interop package, such as PyCall to use geopandas:
import Pkg; Pkg.add(["Conda", "PyCall"])
using Conda, PyCall
Conda.add("geopandas")
geopandas = pyimport("geopandas")
geopandas.__version__ #0.12.2
Thanks for your reply. But it seems not work in my case. I checked the original code which prompts wrong. The original code is showed in the following picture.
Today, I rerun the code, and a different error occured.
I just realized that whether it is the problem of code " py" " " " that julia can’t recognize?The code" py" " " " is the 387th row of NYCPlots.jl.
I receive the same error on Julia 1.6. It is fixed for me on Julia 1.8, so I would suggest, if possible, to update to the latest Julia version. To test it out, I recommend running the following code:
import Pkg; Pkg.add("PyCall")
using PyCall
geopandas = pyimport_conda("geopandas", "geopandas")
path_to_data = geopandas.datasets.get_path("nybb")
gdf = geopandas.read_file(path_to_data)
If it works correctly, you should see “ERROR 1: PROJ: proj_create_from_database: Open of /root/.julia/conda/3/x86_64/share/proj failed”, which appears to be the expected output based on the “Getting Started” section from the docs.
Thanks a lot for your continuous reply. I’ll test the code by using julia1.8.