Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python ctypes.CDLL不加载库,尽管位置是已知的_Python_Ctypes_Importerror_Shapely - Fatal编程技术网

python ctypes.CDLL不加载库,尽管位置是已知的

python ctypes.CDLL不加载库,尽管位置是已知的,python,ctypes,importerror,shapely,Python,Ctypes,Importerror,Shapely,要运行我的一个脚本,我必须使用shapely python包,但它崩溃了,因为它无法加载libgeos库。它向我提供了以下错误消息: Traceback (most recent call last): File "download_nl.py", line 2, in <module> from download_sentinel import sentinel_available, sentinel_download, download_orbits Fi

要运行我的一个脚本,我必须使用shapely python包,但它崩溃了,因为它无法加载libgeos库。它向我提供了以下错误消息:

Traceback (most recent call last):
  File "download_nl.py", line 2, in <module>
    from download_sentinel import sentinel_available, sentinel_download,     download_orbits
  File "/nfs/home2/gmulder/radar_database/download_sentinel.py", line 14, in <module>
    from fastkml import kml
  File "/home/gmulder/python_packages/fastkml/__init__.py", line 30, in <module>
    from .kml import KML, Document, Folder, Placemark
  File "/home/gmulder/python_packages/fastkml/kml.py", line 37, in <module>
    from .geometry import Geometry
  File "/home/gmulder/python_packages/fastkml/geometry.py", line 23, in <module>
    from shapely.geometry import Point, LineString, Polygon
  File "/home/gmulder/python_packages/shapely/geometry/__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "/home/gmulder/python_packages/shapely/geometry/base.py", line 9, in <module>
    from shapely.coords import CoordinateSequence
  File "/home/gmulder/python_packages/shapely/coords.py", line 8, in <module>
    from shapely.geos import lgeos
  File "/home/gmulder/python_packages/shapely/geos.py", line 73, in <module>
    _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
  File "/home/gmulder/python_packages/shapely/geos.py", line 68, in load_dll
    libname, fallbacks or []))
OSError: Could not find lib geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'].
为了检查代码是否可以找到所需的lib文件位置,我在第7行添加了额外的检查,以确认库在那里。但是,当我尝试加载它时,没有加载任何内容,即使我直接将完整路径提供给CDLL函数。 我还尝试通过运行python并以交互方式(而不是通过python脚本)打开库来加载库,效果很好。因此,我检查了python版本,因为我认为这可能会导致这个问题。但是我的脚本和交互式会话的python版本是相同的。有人能帮我吗?可能我遗漏了什么,但我不知道是什么导致了这个问题

def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE):
    lib = find_library(libname)
    dll = None
    print(sys.version)
    dirname = '/hpc/sw/geos-3.5.0/lib'
    os.environ['PATH'] = dirname + os.pathsep + os.environ['PATH']
    if os.path.exists(os.path.join(dirname, 'libgeos_c.so.1')):
        print('library does exist!')
    os.chdir(dirname)
    if lib is not None:
    try:
        LOG.debug("Trying `CDLL(%s)`", lib)
        dll = CDLL(lib)
    except OSError:
        LOG.warn("Failed `CDLL(%s)`", lib)
        pass

    if not dll and fallbacks is not None:
        for name in fallbacks:
            try:
                LOG.debug("Trying `CDLL(%s)`", name)
                dll = CDLL(name)
            except OSError:
                # move on to the next fallback
                LOG.warn("Failed `CDLL(%s)`", name)
                pass

    print(dll)
    if dll:
        LOG.debug("Library path: %r", lib or name)
        LOG.debug("DLL: %r", dll)
        return dll
    else:
        # No shared library was loaded. Raise OSError.
        raise OSError(
            "Could not find lib {0} or load any of its variants    {1}.".format(
                libname, fallbacks or []))