Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add import check for shapely/geos #110

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/sphinx/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍



pvlib implementation
Expand Down
16 changes: 16 additions & 0 deletions pvfactors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

)
err.strerror += "; " + msg
raise err


class PVFactorsError(Exception):
pass