pvlib / pvlib-python

A set of documented functions for simulating the performance of photovoltaic energy systems.
https://pvlib-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.16k stars 979 forks source link

latest version of pvfactors cannot be installed with pvlib 0.10.0 #1796

Closed kandersolar closed 1 year ago

kandersolar commented 1 year ago

The last several versions of pvfactors require pvlib<0.10 to preempt possible breaking changes. In fact this turned out to be unnecessary; to the best of my knowledge, there is no actual incompatibility between pvfactors==1.5.2 (the latest) and pvlib==0.10.0.

However, that upper limit does prevent pip from installing pvfactors==1.5.2 and pvlib==0.10.0 simultaneously. What it does instead is go back to pvfactors==1.4.1, the last version that doesn't require pvlib<0.10. The problem is that this version of pvfactors is old enough to not contain a compatibility fix with the latest shapely, resulting in a broken installation that errors when you try to actually use pvfactors. See for example this failed docs build: https://readthedocs.org/projects/pvlib-python/builds/21171307/

Users have two options to work around this problem in the immediate term. Option 1: downgrade shapely to a version that works with pvfactors==1.4.1:

$ pip install pvlib==0.10.0 pvfactors  # installs pvfactors 1.4.1 and shapely 2.x
$ pip install 'shapely<2.0'  # might need to use double quotes in some terminals

Option 2: tell pip to ignore pvfactors when it says it isn't compatible with pvlib 0.10.0. This will allow you to keep using pvfactors 1.5.2:

$ pip install pvfactors==1.5.2  # installs pvlib 0.9.5, and shapely 1.8.5
$ pip install --no-deps pvlib==0.10.0  # installs pvlib 0.10.0 alongside pvfactors 1.5.2

For a more permanent fix, the best solution would be for pvfactors to release a new version that doesn't have this unnecessary pvlib<0.10 requirement. But since that project is no longer maintained, we can't expect that to happen.

In the absence of that, I see two options, both of which require going to 0.10.1:


An aside: although I did make a local v0.10.0 tag and ensure that the tests passed before making the official 0.10.0 release, I neglected to install pvlib[optional] in the fresh test environment, so the pvfactors tests were skipped and this problem did not arise. Had I been more thorough, this problem could have been found out before pvlib 0.10.0 was actually released.

saikatghosh90 commented 1 year ago

I tried both but still getting errors , also i am unable to figure out how to replace the pvfactor code with solarfactors.

Can you update this code which is given as example by pvlib, with exactly what lines to be changed ? https://pvlib-python.readthedocs.io/en/stable/gallery/bifacial/plot_bifi_model_pvwatts.html#sphx-glr-gallery-bifacial-plot-bifi-model-pvwatts-py [autoreload of pvlib.atmosphere failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 496, in superreload update_generic(old_obj, new_obj) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 393, in update_generic update(a, b) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 305, in update_function setattr(old, name, getattr(new, name)) ValueError: first_solar_spectral_correction() requires a code object with 0 free vars, not 3 ] [autoreload of pvlib.pvsystem failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 496, in superreload update_generic(old_obj, new_obj) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 393, in update_generic update(a, b) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 305, in update_function setattr(old, name, getattr(new, name)) ValueError: sapm_spectral_loss() requires a code object with 0 free vars, not 3 ] [autoreload of pvlib.modelchain failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 496, in superreload update_generic(old_obj, new_obj) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 393, in update_generic update(a, b) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 345, in update_class if update_generic(old_obj, new_obj): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 393, in update_generic update(a, b) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 305, in update_function setattr(old, name, getattr(new, name)) ValueError: repr() requires a code object with 2 free vars, not 0 ] [autoreload of pvfactors failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 471, in superreload module = reload(module) File "C:\Users\SaikatGhosh\anaconda3\lib\importlib__init.py", line 169, in reload _bootstrap._exec(spec, module) File "", line 613, in _exec File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\pvfactors__init__.py", line 8, in from shapely.geos import lgeos ImportError: cannot import name 'lgeos' from 'shapely.geos' (C:\Users\SaikatGhosh\anaconda3\lib\site-packages\shapely\geos.py) ] [autoreload of pvfactors.geometry.plot failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 471, in superreload module = reload(module) File "C:\Users\SaikatGhosh\anaconda3\lib\importlib\init.py", line 159, in reload raise ImportError(msg.format(parent_name), ImportError: parent 'pvfactors.geometry' not in sys.modules ] [autoreload of pvfactors.geometry.utils failed: Traceback (most recent call last): File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 273, in check superreload(m, reload, self.old_objects) File "C:\Users\SaikatGhosh\anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 471, in superreload module = reload(module) File "C:\Users\SaikatGhosh\anaconda3\lib\importlib\init__.py", line 159, in reload raise ImportError(msg.format(parent_name), ImportError: parent 'pvfactors.geometry' not in sys.modules ] Traceback (most recent call last):

File ~\anaconda3\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec exec(code, globals, locals)

File c:\users\saikatghosh\clipping.py:256 irrad = pvfactors_timeseries(solar_position['azimuth'],

File ~\anaconda3\lib\site-packages\pvlib\bifacial\pvfactors.py:97 in pvfactors_timeseries from pvfactors.run import run_timeseries_engine

File ~\anaconda3\lib\site-packages\pvfactors\run.py:5 from pvfactors.geometry import OrderedPVArray

File ~\anaconda3\lib\site-packages\pvfactors\geometry__init__.py:3 from pvfactors.geometry.pvarray import OrderedPVArray

File ~\anaconda3\lib\site-packages\pvfactors\geometry\pvarray.py:6 from pvfactors.geometry.base import \

File ~\anaconda3\lib\site-packages\pvfactors\geometry\base.py:12 from shapely.geometry.collection import geos_geometrycollection_from_py

ImportError: cannot import name 'geos_geometrycollection_from_py' from 'shapely.geometry.collection' (C:\Users\SaikatGhosh\anaconda3\lib\site-packages\shapely\geometry\collection.py)