# PyCall Won't import gdal or osr

**URL:** <https://discourse.julialang.org/t/pycall-wont-import-gdal-or-osr/36168>\
**Category:** General Usage\
**Tags:** pycall\
**Created:** [March 18, 2020, 11:59pm UTC](https://discourse.julialang.org/t/pycall-wont-import-gdal-or-osr/36168 "2020-03-18T23:59:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scone](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@scone](https://discourse.julialang.org/u/scone)\
**Post date:** [March 18, 2020, 11:59pm UTC](https://discourse.julialang.org/t/pycall-wont-import-gdal-or-osr/36168/1 "2020-03-18T23:59:34Z")

</div>

Hi everyone,

I wrote some code a few months ago that was working fine. Now that I am trying to use it again on the same computer without changing the code, I can’t import gdal or osr with pycall. However, numpy still imports without issue! I tried importing both packages from the python3 terminal an there were no errors. Here is the code and error:

```julia
using PyCall
using JLD
np=pyimport("numpy")
gdal = pyimport("gdal")
osr = pyimport("osr")

```

```julia
ERROR: PyCall.PyError("PyImport_ImportModule\n\nThe Python package osr could not be found by pyimport. Usually this means\nthat you did not install osr in the Python version being used by PyCal
l.\n\nPyCall is currently configured to use the Python version at:\n\n/usr/bin/python3\n\nand you should use whatever mechanism you usually use (apt-get, pip, conda,\netcetera) to install the P
ython package containing the osr module.\n\nOne alternative is to re-configure PyCall to use a different Python\nversion on your system: set ENV[\"PYTHON\"] to the path/name of the python\nexec
utable you want to use, run Pkg.build(\"PyCall\"), and re-launch Julia.\n\nAnother alternative is to configure PyCall to use a Julia-specific Python\ndistribution via the Conda.jl package (which installs a private Anaconda\nPython distribution), which has the advantage that packages can be installed\nand kept up-to-date via Julia. As explained in the PyCall documentation,\nset ENV[\"PYTHON\"]=\"\", run Pkg.build(\"PyCall\"), and re-launch Julia. Then,\nTo install the osr module, you can use `pyimport_conda(\"osr\", PKG)`,\nwhere PKG is the Anaconda package the contains the module osr,\nor alternatively you can use the Conda package directly (via\n`using Conda` followed by `Conda.add` etcetera).\n\n", PyObject(Ptr{PyCall.PyObject_struct} @0x00007fb2fa4b0f60), PyObject(Ptr{PyCall.PyObject_struct} @0x00007fb2f6398a50), PyObject(Ptr{PyCall.PyObject_struct} @0x00007fb2f639a3c0))

```

Anyone have an idea? This is very frustrating. Thanks

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 19, 2020, 12:15am UTC](https://discourse.julialang.org/t/pycall-wont-import-gdal-or-osr/36168/2 "2020-03-19T00:15:54Z")

</div>

You mean _ogr_ instead of _osr_?  
And at GDAL2.0 there was a merge of GDAL+OGR so likely you only want to import _gdal_

---

<div class="post-metadata">

**Author:** ![scone](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@scone](https://discourse.julialang.org/u/scone)\
**Post date:** [March 19, 2020, 12:20am UTC](https://discourse.julialang.org/t/pycall-wont-import-gdal-or-osr/36168/3 "2020-03-19T00:20:23Z")

</div>

I have never used ogr. This code was working in December or January. I get the same error from trying to import gdal as osr, though they are both installed for python3…
