0

I am not able to read shape files anymore after installing pygeos. What a mess!

these lines used to work fine

files = glob.iglob(path_to_data+shapes_folder+'*.shp')
gdfs = [gpd.read_file(file).to_crs(crs) for file in files]

But when I installed pygeos for other work, problems started and i get this error when running exactly those same lines. Here is the error:

NameError                                 Traceback (most recent call last)
Cell In [68], line 1
----> 1 geomap = import_shapes_list(path_to_data=path_to_data,shapes_folder=shapes_folder,crs='EPSG:4326')

Cell In [64], line 5, in import_shapes_list(path_to_data, shapes_folder, crs)
      2 """
      3 """
      4 files = glob.iglob(path_to_data+shapes_folder+'*.shp')
----> 5 gdfs = [gpd.read_file(file).to_crs(crs) for file in files]
      6 for gdf in gdfs:
      7     gdf.columns = map(str.lower, gdf.columns)

Cell In [64], line 5, in <listcomp>(.0)
      2 """
      3 """
      4 files = glob.iglob(path_to_data+shapes_folder+'*.shp')
----> 5 gdfs = [gpd.read_file(file).to_crs(crs) for file in files]
      6 for gdf in gdfs:
      7     gdf.columns = map(str.lower, gdf.columns)

File c:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\geopandas\io\file.py:253, in _read_file(filename, bbox, mask, rows, engine, **kwargs)
    250     path_or_bytes = filename
    252 if engine == "fiona":
--> 253     return _read_file_fiona(
...
--> 121     if compat.USE_PYGEOS and isinstance(geom, pygeos.Geometry):
    122         out.append(geom)
    123     elif isinstance(geom, BaseGeometry):

NameError: name 'pygeos' is not defined

I tried uninstall pygeos but it won't let me. I get this error:

pip uninstall pygeos
Found existing installation: pygeos 0.13
Uninstalling pygeos-0.13:
  Would remove:
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos-0.13.dist-info\*
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos.libs\.load-order-pygeos-0.13
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos.libs\geos-1ea75348dbc255af1c28c7962b3b3574.dll
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos.libs\geos_c-1be6adb5df796a999943a2118bad6f1e.dll
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos.libs\msvcp140.dll
    c:\users\badao\desktop\python yamed\venv\lib\site-packages\pygeos\*
Proceed (Y/n)? Y
  Successfully uninstalled pygeos-0.13
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\commands\uninstall.py", line 103, in run
    uninstall_pathset.commit()
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\req\req_uninstall.py", line 424, in commit
    self._moved_paths.commit()
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\req\req_uninstall.py", line 277, in commit
    save_dir.cleanup()
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\utils\temp_dir.py", line 173, in cleanup
    rmtree(self._path)
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 326, in wrapped_f
    return self(f, *args, **kw)
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 406, in __call__
    do = self.iter(retry_state=retry_state)
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 362, in iter
    raise retry_exc.reraise()
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 195, in reraise
    raise self.last_attempt.result()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 451, in result
    return self.__get_result()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 409, in __call__
    result = fn(*args, **kwargs)
  File "C:\Users\badao\Desktop\Python Yamed\venv\lib\site-packages\pip\_internal\utils\misc.py", line 128, in rmtree
    shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 749, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 619, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 617, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\badao\\Desktop\\Python Yamed\\venv\\Lib\\site-packages\\~ygeos.libs\\geos-1ea75348dbc255af1c28c7962b3b3574.dll'

what happened?

bravopapa
  • 309
  • 1
  • 10

0 Answers0