diff --git a/docs/sphinx/installation/index.rst b/docs/sphinx/installation/index.rst index 28cbab8c..e28a478a 100644 --- a/docs/sphinx/installation/index.rst +++ b/docs/sphinx/installation/index.rst @@ -15,6 +15,17 @@ The easiest way to install ``pvfactors`` is using pip_: $ pip install pvfactors +However, installing ``shapely`` from PyPI may not install all the necessary binary dependencies. +If you run into an error like ``OSError: [WinError 126] The specified module could not be found``, +try installing conda from conda-forge with: + +.. code-block:: shell + + $ conda install -c conda-forge shapely + +Windows users may also be able to resolve the issue by installing wheels from `Christoph Gohlke`_. + +.. _Christoph Gohlke: https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely pvlib implementation diff --git a/pvfactors/__init__.py b/pvfactors/__init__.py index cd5bb836..50f168e0 100644 --- a/pvfactors/__init__.py +++ b/pvfactors/__init__.py @@ -4,6 +4,22 @@ import logging logging.basicConfig() +try: + from shapely.geos import lgeos +except OSError as err: + # https://github.com/SunPower/pvfactors/issues/109 + msg = ( + "pvfactors encountered an error when importing the shapely package. " + "This often happens when a binary dependency is missing because " + "shapely was installed from PyPI using pip. Try reinstalling shapely " + "from another source like conda-forge with " + "`conda install -c conda-forge shapely`, or alternatively from " + "Christoph Gohlke's website if you're on Windows: " + "https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely" + ) + err.strerror += "; " + msg + raise err + class PVFactorsError(Exception): pass