Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: gdal import error #6215

Open
dreyerlivio opened this issue Feb 1, 2025 · 5 comments
Open

Python: gdal import error #6215

dreyerlivio opened this issue Feb 1, 2025 · 5 comments
Labels
bug Something isn't working info needed Waiting on information lang: python support

Comments

@dreyerlivio
Copy link

dreyerlivio commented Feb 1, 2025

System details:

Positron Version: 2025.02.0 (system setup) build 137
Code - OSS Version: 1.96.0
Commit: f4b7966
Date: 2025-01-30T15:18:06.013Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631

Describe the issue:

Importing gdal gives the following error:

>>> from osgeo import gdal
ModuleNotFoundError: No module named '_gdal'
File ~\miniconda3\envs\nc_reproject\Lib\site-packages\osgeo\__init__.py:30, in swig_import_helper()
     29 try:
---> 30     return importlib.import_module(mname)
     31 except ImportError:
Show Traceback
File [~\miniconda3\envs\nc_reproject\Lib\importlib\__init__.py:90](vscode-file://vscode-app/c:/Program%20Files/Positron/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#), in import_module(name, package)
     89         level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:921, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:813, in module_from_spec(spec)

File <frozen importlib._bootstrap_external>:1289, in create_module(self, spec)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

ImportError: DLL load failed while importing _gdal: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 1
----> 1 from osgeo import gdal

File [~\miniconda3\envs\nc_reproject\Lib\site-packages\osgeo\__init__.py:35](vscode-file://vscode-app/c:/Program%20Files/Positron/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#)
     31     except ImportError:
     32         return importlib.import_module('_gdal')
---> 35 _gdal = swig_import_helper()
     36 del swig_import_helper
     38 __version__ = _gdal.__version__ = _gdal.VersionInfo("RELEASE_NAME")

File [~\miniconda3\envs\nc_reproject\Lib\site-packages\osgeo\__init__.py:32](vscode-file://vscode-app/c:/Program%20Files/Positron/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#), in swig_import_helper()
     30     return importlib.import_module(mname)
     31 except ImportError:
---> 32     return importlib.import_module('_gdal')

File [~\miniconda3\envs\nc_reproject\Lib\importlib\__init__.py:90](vscode-file://vscode-app/c:/Program%20Files/Positron/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#), in import_module(name, package)
     88             break
     89         level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)

Import works fine in command line or other IDE's. Import worked fine in version 2024.11.0-140, for newer versions this gives the error above.

Steps to reproduce the issue:

In python console: from osgeo import gdal

@dreyerlivio dreyerlivio changed the title gdal import error Python: gdal import error Feb 2, 2025
@seeM
Copy link
Contributor

seeM commented Feb 3, 2025

Thank you for the feedback @dreyerlivio!

Is 2024.11.0-140 the last version where this worked correctly? Have you tried 2024.12.0-41 or any other later versions?

If you're able to find the latest working version that would really help us narrow down this regression.

@seeM seeM added info needed Waiting on information bug Something isn't working lang: python support labels Feb 3, 2025
@dreyerlivio
Copy link
Author

dreyerlivio commented Feb 3, 2025

2024.11.0-140 is the latest working version, not working with newer versions. Manuallly defining the path as below fixes the issues,so I guess Positron does not correctly set this path anymore

library_bin = r"C:\Users\xxx\miniconda3\envs\nc_reproject\Library\bin"
if library_bin not in os.environ["PATH"]:
  os.environ["PATH"] = library_bin + ";" + os.environ["PATH"]

@seeM
Copy link
Contributor

seeM commented Feb 4, 2025

Thank you @dreyerlivio, this is a really helpful clue. We will investigate and post any findings here ASAP

@seeM seeM removed the info needed Waiting on information label Feb 4, 2025
@isabelizimm
Copy link
Contributor

Hi there! Thank you for reporting this issue and the follow up. I just tried this out on a Windows 10 (😅) machine on Positron Version: 2025.01.0 (system setup) build 159 and was able to import gdal as expected.

Here's a little bit more about my setup.

  • Miniconda 25.1.1
  • Python 3.11.11
  • gdal 3.6.2, installed with conda install gdal

Are you able to 1) try out the latest Positron release and see if that fixes your issue or 2) give a bit more info about your environment, specifically gdal, Python, conda versions, and how you installed gdal?

@juliasilge juliasilge added the info needed Waiting on information label Feb 11, 2025
@dreyerlivio
Copy link
Author

Just tried with the newest release, still the same error.

My environment on a windows 11 machine:

  • Miniconda 24.11.3
  • Python 3.11.4
  • gdal 3.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working info needed Waiting on information lang: python support
Projects
None yet
Development

No branches or pull requests

4 participants