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

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

Closed
kandersolar opened this issue Jun 30, 2023 · 1 comment · Fixed by #1797
Closed

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

kandersolar opened this issue Jun 30, 2023 · 1 comment · Fixed by #1797

Comments

@kandersolar
Copy link
Member

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:

  • A simple solution would be to add shapely<2.0 to our optional requirements, effectively making Option 1 above automatic. This has the downside of using an older version of pvfactors, which is missing a minor bugfix that a small minority of users might care about.
  • Another option is to use this as motivation to get solarfactors sufficiently up to speed such that we could switch pvlib to depend on it instead of pvfactors. I will look into how much work that would take.

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
Copy link

saikatghosh90 commented Sep 5, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants