makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
712 stars 282 forks source link

Specified module could not be found #244

Open vincz100 opened 5 years ago

vincz100 commented 5 years ago

Hi, while I'm trying to use django-leaflet following the installation documentation and add leaflet to my INSTALLED_APPS I have this error message (I'm working with Django 2.1.3) :

(dev) C:\Users\ferra\Dev\django-leaflet\example>python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000195F64F16A8>
Traceback (most recent call last):
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\core\management\__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)  File "C:\Users\ferra\Anaconda3\envs\dev\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\ferra\Dev\django-leaflet\example\mushrooms\models.py", line 1, in <module>
    from djgeojson.fields import PolygonField
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\djgeojson\fields.py", line 8, in <module>
    from leaflet.forms.widgets import LeafletWidget
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\leaflet\forms\widgets.py", line 11, in <module>
    from django.contrib.gis.forms.widgets import BaseGeometryWidget
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
    from django.contrib.gis.geos import GEOSException, GEOSGeometry
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\geos\__init__.py", line 5, in <module>
    from .collections import (  # NOQA
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\geos\collections.py", line 9, in <module>
    from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\geos\geometry.py", line 8, in <module>
    from django.contrib.gis import gdal
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in <module>
    from django.contrib.gis.gdal.driver import Driver
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\drive
r.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\prototy
pes\ds.py", line 9, in <module>
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>    from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
  File "C:\Users\ferra\Anaconda3\envs\dev\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in <module>
    lgdal = CDLL(lib_path)  File "C:\Users\ferra\Anaconda3\envs\dev\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Le module spécifié est introuvable
Ob024 commented 5 years ago

Almost the same problem, been fighting it for days with no luck no matter what I try... no even sure which module is missing because it has a problem finding GDAL then finds that, then has a problem cause no psycopg so I pip install psycopg2 and/or psycopg2-binarys and then end up with the module cant be found... I can cause the same bug by trying to: django.contrib.gis.db import models but when I try to import that with the python on my system, the only version of python I have, it works fine.... So I really have no clue what is happening... I did have to add some versions to the libgdal.py file because it stopped at 202 and 203 and 204 are the newer dll's - saw another user mention he had to add 203 to get his to work.. not sure why mine wont, starting to think its a requirement of gdal that is missing instead of gdal but no idea what, it does not give you enough information in the error.

Traceback (most recent call last): File "manage.py", line 15, in execute_from_command_line(sys.argv) File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\core\management__init.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\core\management__init.py", line 357, in execute django.setup() File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\apps\registry.py", line 120, in populate app_config.ready() File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\admin\apps.py", line 24, in ready self.module.autodiscover() File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\admin\init.py", line 26, in autodiscover autodiscover_modules('admin', register_to=site) File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "C:\Program Files (x86)\Python37-32\lib\importlib\init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\admin\init.py", line 5, in from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in from django.contrib.gis.admin.widgets import OpenLayersWidget File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\admin\widgets.py", line 3, in from django.contrib.gis.gdal import GDALException File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\gdal\init.py", line 28, in from django.contrib.gis.gdal.datasource import DataSource File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in from django.contrib.gis.gdal.driver import Driver File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal File "C:\Users\Oobs\PycharmProjects\GeoToke\venv\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in lgdal = CDLL(lib_path) File "C:\Program Files (x86)\Python37-32\lib\ctypes\init.py", line 356, in init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 126] The specified module could not be found

pauelm commented 4 years ago

I am experiencing the same issue. Given that the latest and greatest code base in the repo is completely busted, and obviously having been busted for several years, it is safe to say that this project is no longer supported. I was looking forward to potentially leveraging leaflet and really needed to see some actual working examples, but sadly, there does not appear to be any, and this project is a dead end.

Perhaps there are other actual working examples of leaflet with django somewhere, but given that working examples of leaflet and django in action are elusive, it is likely that leaflet as a whole will be replaced with better options as well. There are just too many dead bodies of busted project relics laying around. Ironically, when we look for some baseline solution examples in the effort to save time, so much unsupported garbage we run into turns into a huge waste of time. I almost wish that there were rating systems in place for code bases in different repos on GH, and that if they reach a certain point level / percentage of low enough points, such public project repos automatically become frozen, made privately until new fixes are in place, and if they are not touched after 60 days, the repo is archived, sent to the owner, and the repo is wiped from GH for garbage cleanup. Seems like a pragmatic solution.

Gagaro commented 4 years ago

Instead of ranting for nothing, feel free to contribute and actually add something to the conversation.

You're hitting an edge case that we couldn't reproduce. You're probably on windows, so start by listing what versions you have, the exact traceback, etc so we can actually hopefully help solve this issue.

pauelm commented 4 years ago

Gagaro, that is not a rant. That is constructive feedback.

I came across this issue thread when ran into the same problem and investigating it. This is definitely not an "edge case". If you don't have bandwidth to resolve, I can understand that. However, insinuating that this issue is a problem with Windows without any information to support it, is totally different, and is dubious at best. This has been an open, showstopping issue for about 2 years now, and users with this issue have been ignored up to this point, while also no solutions have been offered to any of the previous users that have encountered this same issue. Also, this issue is not the only issue with django-leaflet that has gone largely ignored or unresolved. Many users have simply given up as issues repeatedly go unresolved. If there are new efforts underway to remove such patterns, then great. Can't reproduce it? To start, try running it on Windows with any component version combination, and see if you can repro this defect.

If you still cannot reproduce it, then provide the versions of components you have running, and any other essential configuration information that allows you to run the mushroom web application without issues, and I can try it as well and see if it resolves this showstopping issue. Otherwise, if Windows is not supported with django-leaflet, then say so, and users will know to avoid it when working with Windows, and look for different solution that might work. If you suspect a configuration and / or version compatibility issue somewhere, then offer other suggestions to try. I will continue troubleshooting with different version components as well, and see if I come up with a different outcome. If I can get django-leaflet running with the mushroom web application, I will provide an update, along with with what I did to resolve it.

Steps:

  1. Install Django 3.1.
  2. pip install django-leaflet 0.27.1
  3. Open the project and navigate terminal to .\django-leaflet-master\example
  4. Enter python manage.py runserver (You can also try any option and / or order of python manage-py migrate / ****

Expected Results: Server will fire off and run without errors and mushroom django web application runs in the browser without issues.

Actual Results: The following error is thrown: OSError: [WinError 126]

Installations: django-leaflet: 0.27.1 django-geojson: 3.0.0 Django: 3.1 Python: 3.8.5, 3.7.6, 3.6.6 Anaconda: 4.8.3 VS Code: 1.47.3 Windows 10 Build 19041.388

Ob024 commented 4 years ago

My problems with GDAL and psycopg2 had more to do with the fact I had a really old install of windows that was corrupt with mixed x32 and x64 versions of lots of the DLL's that were not playing friendly with each other. Its been awhile now so I am not 100% sure i got everything with leaflet working but I got the GDAL/psycopg2 stuff working correctly at some point. So if you are having problems with your GDAL/Psycopg2 then look into your DLL versions, if they are a mixture of 32 and 64bit then it might be having problem working with them. Good Luck!