conda环境PIE云开发SDK导入问题解决

在使用Python PIE SDK时遇到了导入Shapely库的OSError。问题源于Conda环境中Shapely库的加载失败,具体表现为找不到指定模块'geos_c.dll'。解决方案是通过Conda重新安装Shapely库,执行'conda install shapely'后,成功解决了导入问题,能够正常运行PIE的PythonSDK。
摘要由CSDN通过智能技术生成

问题描述:

PythonPIE版本:0.1.4
python版本:3.7.10
conda版本:4.10.0

在Conda环境中使用PIE的Python SDK遇到如下报错:

>>> import pie

## 输出
OSError                                   Traceback (most recent call last)
<ipython-input-5-a1c6718efd24> in <module>
----> 1 import pie
      2 # import pie.pieleaflet as pieleaflet
      3 
      4 # 使用用户在平台上注册时的用户名/密码
      5 # pie.initialize("**", "**")

D:\anaconda3\envs\pie_dev\lib\site-packages\pie\__init__.py in <module>
     12 from .imageCollection import PIEImageCollection as ImageCollection
     13 from .kernel import PIEKernel as Kernel
---> 14 from .map import PIEMap as Map
     15 from .reducer import PIEReducer as Reducer
     16 from .projection import PIEProjection as Projection

D:\anaconda3\envs\pie_dev\lib\site-packages\pie\map.py in <module>
     11 
     12 import folium
---> 13 import ipyleaflet
     14 from folium import GeoJson, features, vector_layers
     15 # from folium.plugins import TileLayerWithHeaders

D:\anaconda3\envs\pie_dev\lib\site-packages\ipyleaflet\__init__.py in <module>
      9 
     10 try:
---> 11     from .leaflet import *  # noqa
     12     from .basemaps import basemaps   # noqa
     13 except ImportError:

D:\anaconda3\envs\pie_dev\lib\site-packages\ipyleaflet\leaflet.py in <module>
     21 
     22 from branca.colormap import linear, ColorMap
---> 23 from shapely import geometry, wkt
     24 
     25 from ._version import EXTENSION_VERSION

D:\anaconda3\envs\pie_dev\lib\site-packages\shapely\geometry\__init__.py in <module>
      2 
      3 
----> 4 from .base import CAP_STYLE, JOIN_STYLE
      5 from .geo import box, shape, asShape, mapping
      6 from .point import Point, asPoint

D:\anaconda3\envs\pie_dev\lib\site-packages\shapely\geometry\base.py in <module>
     17 
     18 from shapely.affinity import affine_transform
---> 19 from shapely.coords import CoordinateSequence
     20 from shapely.errors import WKBReadingError, WKTReadingError
     21 from shapely.geos import WKBWriter, WKTWriter

D:\anaconda3\envs\pie_dev\lib\site-packages\shapely\coords.py in <module>
      6 from ctypes import byref, c_double, c_uint
      7 
----> 8 from shapely.geos import lgeos
      9 from shapely.topology import Validating
     10 

D:\anaconda3\envs\pie_dev\lib\site-packages\shapely\geos.py in <module>
    152     if os.getenv('CONDA_PREFIX', ''):
    153         # conda package.
--> 154         _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
    155     else:
    156         try:

D:\anaconda3\envs\pie_dev\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: [WinError 126] 找不到指定的模块。

原因分析:

在Traceback的报错消息中,可能发现是conda环境`shapely`库的调用出现问题
    152     if os.getenv('CONDA_PREFIX', ''):
    153         # conda package.
--> 154         _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
    155     else:
    156         try:

遂搜索shapely库的import问题,在StackOverflow中找到相关解答。


解决方案:

安装完毕Conda环境的PIE的python SDK后,再用Conda重装一下Shapely库

conda install shapely

成功导入pie
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值