我开始按照网站指南1使用Python中的pvfactors工具(该工具可计算入射到光伏阵列表面的辐照度)。
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
import pandas as pd
import warnings
warnings.filterwarnings("ignore", category=RuntimeWarning)
# Settings
'exec(%matplotlib inline)'
np.set_printoptions(precision=3, linewidth=300)
#Get timeseries inputs
df_inputs = pd.DataFrame(
{'solar_zenith': [20., 50.],
'solar_azimuth': [110., 250.],
'surface_tilt': [10., 20.],
'surface_azimuth': [90., 270.],
'dni': [1000., 900.],
'dhi': [50., 100.],
'albedo': [0.2, 0.2]},
index=[datetime(2017, 8, 31, 11), datetime(2017, 8, 31, 15)]
)
#Prepare some PV array parameters
pvarray_parameters = {
'n_pvrows': 3, # number of pv rows
'pvrow_height': 1, # height of pvrows (measured at center / torque tube)
'pvrow_width': 1, # width of pvrows
'axis_azimuth': 0., # azimuth angle of rotation axis
'gcr': 0.4, # ground coverage ratio
}
from pvfactors.engine import PVEngine
from pvfactors.geometry import OrderedPVArray
pvarray = OrderedPVArray.init_from_dict(pvarray_parameters)
engine = PVEngine(pvarray)
engine.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi,
df_inputs.solar_zenith, df_inputs.solar_azimuth,
df_inputs.surface_tilt, df_inputs.surface_azimuth,
df_inputs.albedo)
但是,当尝试导入类时,出现以下错误:
OSError: [WinError 126] The specified module could not be found
整个错误消息:
File "C:\Users\karen\OneDrive\Documentos\Doutorado\pvfactors\starting_pvfactors.py", line 51, in from pvfactors.engine import PVEngine
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\engine.py", line 5, in from pvfactors.viewfactors import VFCalculator
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\viewfactors_init_.py", line 3, in from pvfactors.viewfactors.calculator import VFCalculator
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\viewfactors\calculator.py", line 4, in from pvfactors.viewfactors.vfmethods import VFTsMethods
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\viewfactors\vfmethods.py", line 4, in from pvfactors.geometry.timeseries import TsLineCoords, TsPointCoords
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\geometry_init_.py", line 3, in from pvfactors.geometry.pvarray import OrderedPVArray
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\geometry\pvarray.py", line 6, in from pvfactors.geometry.base import \
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\geometry\base.py", line 9, in from pvfactors.geometry.utils import \
File "C:\Users\karen\anaconda3\lib\site-packages\pvfactors\geometry\utils.py", line 6, in from shapely.geometry import \
File "C:\Users\karen\anaconda3\lib\site-packages\shapely\geometry_init_.py", line 4, in from .base import CAP_STYLE, JOIN_STYLE
File "C:\Users\karen\anaconda3\lib\site-packages\shapely\geometry\base.py", line 19, in from shapely.coords import CoordinateSequence
File "C:\Users\karen\anaconda3\lib\site-packages\shapely\coords.py", line 8, in from shapely.geos import lgeos
File "C:\Users\karen\anaconda3\lib\site-packages\shapely\geos.py", line 154, in _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
File "C:\Users\karen\anaconda3\lib\ctypes_init_.py", line 364, in init self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
有人可以帮我解决这个错误吗?
答案 0 :(得分:1)
第二到最后一行:
anaconda3\lib\site-packages\shapely\geos.py", line 154, in _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
表明您的python无法找到Shapely使用的GEOS库。 Shapely是pvfactors中的依赖项。但是,看来您的anaconda环境确实安装了Shapely,因此anaconda或conda环境存在问题。解决方案几乎总是创建一个新环境并激活它。问题的一部分是pvfactors仅分布在PyPI中,并且没有conda forge或anaconda软件包,因此您必须手动从Anaconda安装requirements。幸运的Shapely is on conda forge
在anaconda提示符中尝试此操作(在C:\Users\karen\>
之后输入命令):
(base) C:\Users\karen\> conda create -n myenv
(base) C:\Users\karen\> activate myenv
(myenv) C:\Users\karen\> conda config --env --add channels conda-forge
(myenv) C:\Users\karen\> conda install python pvlib-python shapely matplotlib future six
(myenv) C:\Users\karen\> pip install --no-deps pvfactors
(myenv) C:\Users\karen\> conda install <other stuff like ipython Jupyter spyder etc>
祝你好运。我建议在pvfactors中创建一个问题,并要求他们添加conda forge软件包。
PS:请参见https://docs.conda.io/projects/conda/en/latest/commands/config.html PPS:请参见https://pip.pypa.io/en/stable/reference/pip_install/#install-no-deps