在运行python代码时,报以下错误
D:\ProgramData\Anaconda3\envs\pytorch_gpu\python.exe E:/ZhuoZhuangOCR/Paper/Latest/DB-Resnet/DB/demo.py
Traceback (most recent call last):
File "E:/ZhuoZhuangOCR/Paper/Latest/DB-Resnet/DB/demo.py", line 7, in <module>
from experiment import Structure, Experiment
File "E:\ZhuoZhuangOCR\Paper\Latest\DB-Resnet\DB\experiment.py", line 4, in <module>
from structure.representers import *
File "E:\ZhuoZhuangOCR\Paper\Latest\DB-Resnet\DB\structure\representers\__init__.py", line 1, in <module>
from .seg_detector_representer import SegDetectorRepresenter
File "E:\ZhuoZhuangOCR\Paper\Latest\DB-Resnet\DB\structure\representers\seg_detector_representer.py", line 3, in <module>
from shapely.geometry import Polygon
File "D:\ProgramData\Anaconda3\envs\pytorch_gpu\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "D:\ProgramData\Anaconda3\envs\pytorch_gpu\lib\site-packages\shapely\geometry\base.py", line 18, in <module>
from shapely.coords import CoordinateSequence
File "D:\ProgramData\Anaconda3\envs\pytorch_gpu\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "D:\ProgramData\Anaconda3\envs\pytorch_gpu\lib\site-packages\shapely\geos.py", line 145, in <module>
_lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
File "D:\ProgramData\Anaconda3\envs\pytorch_gpu\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。
对于上面的错误,是在shapely的文件夹里面的代码报的错(要根据具体情况具体分析),可以看出这是由于shapely版本有问题
解决方法:
conda install -c conda-forge shapely
安装完后,可能会出现
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hi
解决方法:加入下面这行代码
import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'
参考链接:
- https://www.codeleading.com/article/10823667722/
- https://blog.csdn.net/peachhhh/article/details/114900589