6

I'm running Python 3.5.4 on Anaconda and i'm trying to install geopandas. I've followed the instructions to install geopandas here - http://geoffboeing.com/2014/09/using-geopandas-windows/ - but whichever way i try i get the same error. I've looked at many pages on gis.stackexchange and other sites that seem to have similar error messages, but none of them had the exact same error message, and no solutions worked for me. I've set up the Path environment variable, C:\Users\joseph.mabe\AppData\Local\Continuum\anaconda3\Lib\site-packages\osgeo; but to no avail.

I wondered if my use of Jupyter was part of the issue?

picture of importerror

3

I had the same exact problem. I fixed it by:

  1. Uninstalling Anaconda and reinstalling, making sure the "Add anaconda to PATH" option was ticked.
  2. Installing geopandas with conda install -c conda-forge geopandas
  3. Uninstalling GDAL with pip uninstall gdal
  4. Installing the GDAL wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal (follow the instructions on the website in your question concerning python and windows version). In my case: pip install GDAL-2.2.4-cp36-cp36m-win_amd64.whl

I do get a DeprecationWarning: DeprecationWarning: gdal.py was placed in a namespace, it is now available as osgeo.gdal, but otherwise it runs without problems in the Jupyter Notebook.

  • 1
    HUGE kudos for the answer above. points 3 and 4 were all that was needed to allow me to get gdal working for me. – Simon S Allen Aug 21 '18 at 4:53
1

You want to be aware that the PATH variable generally applies to operating system execution of application files - those types listed in the PATHEXT variable/list. Python will update the PATH variable, temporarily, while it is running. You can view all your current paths by executing the following two lines:

import sys
print sys.path

What you want to look for isn't the ...\osgeo folder, which you have specifically referenced in your Path, but the \Lib\site-packages\ folder one step above that. THIS is the folder that you really want to reference, because python imports modules that are folders inside a pathed folder, and that have an init.py file inside those module folders.

So two fixes - one would be to add the Path C:\Users\joseph.mabe\AppData\Local\Continuum\anaconda3\Lib\site-packages. Another would by to create a new variable PYTHONPATH with the folder C:\Users\joseph.mabe\AppData\Local\Continuum\anaconda3\Lib\site-packages - this will ensure your modules are loaded.

When you make any changes, ever, to path variables, you have to close and reopen Python (by closing Jupyter) to get them to take effect.

At any time, in the Python shell, you can list out all your modules by typing the following two commands:

help()
modules

You can then import any listed module.

  • Thanks AlecZ. I tried adding both of those Environment variables, but the exact same error message still occurs. – joseph Oct 30 '17 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.