我在项目中安装了django_pyowm,但是django拒绝迁移模型。提到我还没有安装模块的事实。
下面我得到此错误输出:
>>> python3 manage.py makemigrations django_pyowm
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django_pyowm/models.py", line 4, in <module>
from pyowm.webapi25.location import Location as LocationEntity
ImportError: No module named 'pyowm.webapi25'
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/dave/Geo_Django/Django_geo_test/lib/python3.5/site-packages/django_pyowm/models.py", line 4, in <module>
from pyowm.webapi25.location import Location as LocationEntity
ImportError: No module named 'pyowm.webapi25'
首先,我试图找出该库是否安装正确,然后检查了pip和pip3版本。
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django_pyowm
然后
>>> pip3 freeze
certifi==2019.3.9
chardet==3.0.4
Django==1.10.5
django-leaflet==0.24.0
django-pyowm==0.2.0
geojson==2.4.1
idna==2.8
pkg-resources==0.0.0
psycopg2==2.7.7
pyowm==2.10.0
requests==2.21.0
urllib3==1.24.3
我也阅读了这个主题,但是它没有帮助我: pip is not installing pyowm correctly for some reason
我还纠正了settings.py
INSTALLED_APPS = [
'django_pyowm',
]