Hello everyone,
I am having an issue when I try to import the h5py library in a file of a django project that uses PostGIS database backend. The error I am getting is this:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\threading.py", line 980, in _bootstrap_inner
self.run()
File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "C:\python_venvs\test_project\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\python_venvs\test_project\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
File "C:\python_venvs\test_project\lib\site-packages\django\core\management\base.py", line 475, in check
all_issues = checks.run_checks(
File "C:\python_venvs\test_project\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\python_venvs\test_project\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\python_venvs\test_project\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "C:\python_venvs\test_project\lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "C:\python_venvs\test_project\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\python_venvs\test_project\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\python_venvs\test_project\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\python_venvs\test_project\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\django_projects\test_project\test_project\urls.py", line 21, in <module>
path('', include('webapp.urls')),
File "C:\python_venvs\test_project\lib\site-packages\django\urls\conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\django_projects\test_project\webapp\urls.py", line 2, in <module>
from . import views
File "C:\django_projects\test_project\webapp\views.py", line 7, in <module>
from webapp.classes import PlaneGeometry, PVFiller, RoofLite
File "C:\django_projects\test_project\webapp\classes.py", line 1, in <module>
import h5py
File "C:\python_venvs\test_project\lib\site-packages\h5py\__init__.py", line 33, in <module>
from . import version
File "C:\python_venvs\test_project\lib\site-packages\h5py\version.py", line 15, in <module>
from . import h5 as _h5
File "h5py\h5.pyx", line 1, in init h5py.h5
ImportError: DLL load failed while importing defs: No se encontró el proceso especificado.
After a lot of testing, I figured out that the problem has to do with the use of PostGIS backend, since if I change the database to sqlite, the import error does not occur. Also, PostGIS db is working fine if I do not include the h5py import. So for me looks like some sort of incompatibility or that I am missing some important configuration step.
I have looked on the internet to see if people are having the same problem, without luck. So I am not sure if it is very specific or if I am doing something wrong.
I hope someone could help me with this, since I’ve tried to solve it for a few days without any success.
Thank you very much in advance.
EDIT: I am using a Windows 10 machine