"OSError:[WinError 126]找不到指定的模块".使用pvfactors库 [英] "OSError: [WinError 126] The specified module could not be found" using pvfactors library
问题描述
我开始按照网站教程但是,当尝试导入类时,出现以下错误:
However, when trying to import the classes, I got the following error:
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
有人可以帮助我解决此错误吗?
Can someone please help me solve this bug?
推荐答案
第二到最后一行:
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软件包,因此您必须安装 Shapely正在conda forge上
shows that your python cannot find the GEOS library that Shapely uses. Shapely is a dependency in pvfactors. However it appears your anaconda environment does have Shapely installed, so there is something wrong either with anaconda or your conda environment. The solution for this is almost always to create a new environment and activate it. Part of the problem is that pvfactors is only distributed in PyPI, and doesn't have a conda forge or anaconda package, so you have to install the requirements from Anaconda manually. Luckily Shapely is on conda forge
在anaconda提示符中尝试此操作(在 C:\ Users \ karen \>
之后输入命令):
Try this in an anaconda prompt (enter commands after 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软件包.
Good luck. I would recommend creating an issue in pvfactors and ask them to add a conda forge package.
PS:请参见 https://docs.conda.io/projects/conda/en/latest/commands/config.html PPS:请参见 https://pip.pypa.io/zh_CN/stable/reference/pip_install/#install-no-deps
PS: see https://docs.conda.io/projects/conda/en/latest/commands/config.html PPS: see https://pip.pypa.io/en/stable/reference/pip_install/#install-no-deps
这篇关于"OSError:[WinError 126]找不到指定的模块".使用pvfactors库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!