簡體   English   中英

“OSError: [WinError 126] 找不到指定的模塊”使用 pvfactors 庫

[英]"OSError: [WinError 126] The specified module could not be found" using pvfactors library

我按照網站教程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

有人可以幫我解決這個錯誤嗎?

倒數第二行:

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 的要求 幸運的是Shapely 在 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-無依賴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM