我有一个现有的 Django 项目。我想将 Wagtail 与它一起使用。 我已按照此处的说明进行操作: http://docs.wagtail.io/en/v1.9/getting_started/integrating_into_django.html
但是,当我尝试启动我的应用程序时,我收到来自 uWSGI 的以下错误消息:-
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "./core/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/opt/django/env/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/opt/django/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/django/env/lib/python2.7/site-packages/django
/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/opt/django/env/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named wagtail
unable to load app 0 (mountpoint='') (callable not found or import error)
导入错误:没有名为 wagtail 的模块
但是我已经安装了 wagtail。
我发现了这个https://github.com/wagtail/wagtaildemo/issues/32
哪个建议
请运行 pip freeze 并将输出粘贴到此处吗?
我运行了 pip freeze,结果是这样的:-
Django==1.9.12
Pillow==3.0.0
Unidecode==0.4.20
Willow==0.4
argparse==1.2.1
assert-exists==0.0.0
backports.ssl-match-hostname==3.5.0.1
beautifulsoup4==4.5.3
caller-module==0.0.0
cp==0.0.0
distribute==0.7.3
django-appconf==1.0.1
django-autocomplete-light==3.2.1
django-compat==1.0.8
django-compressor==1.6
django-dual-authentication==1.0.0
django-hijack==2.0.1
django-htmlmin==0.8.0
django-ipware==1.1.2
django-mathfilters==0.3.0
django-modelcluster==3.0.1
django-taggit==0.22.0
django-treebeard==4.1.0
django-widget-tweaks==1.4.1
djangorestframework==3.6.2
evernote==1.25.1
html5lib==0.9999999
httplib2==0.9.2
not==1.7
oauth2==1.9.0.post1
olefile==0.44
pbr==1.8.1
public==0.0.0
publicsuffix==1.1.0
python-dateutil==2.2
pytz==2015.7
requests==2.13.0
setupfiles==0.0.0
simplejson==3.10.0
six==1.10.0
slackclient==1.0.5
stevedore==1.10.0
svn==0.3.36
uWSGI==2.0.11.2
url==0.1.5
virtualenv==13.1.2
virtualenv-clone==0.2.6
virtualenvwrapper==4.7.1
wagtail==1.9
webencodings==0.5
websocket-client==0.40.0
wheel==0.24.0
wsgiref==0.1.2
上面链接中的下一个故障排除步骤指出:-
如果在 python 命令中输入以下几行,您会得到什么 线?
进口鹡鸰; wagtail 导入 wagtail.wagtailadmin; wagtail.wagtailadmin 导入 wagtail.wagtailforms; wagtail.wagtailforms
这是我在 python 中运行这些命令时的结果:
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wagtail; wagtail
<module 'wagtail' from '/usr/local/lib/python2.7/dist-packages/wagtail/__init__.pyc'>
>>> import wagtail.wagtailadmin; wagtail.wagtailadmin
<module 'wagtail.wagtailadmin' from '/usr/local/lib/python2.7/dist-packages/wagtail/wagtailadmin/__init__.pyc'>
>>> import wagtail.wagtailforms; wagtail.wagtailforms
<module 'wagtail.wagtailforms' from '/usr/local/lib/python2.7/dist-packages/wagtail/wagtailforms/__init__.pyc'>
>>>
为什么我收到“没有名为 wagtail 的模块”错误?
您似乎安装了两个 python 2.7,也许是内置的一个,以及手动安装的一个。显示导入错误的那个使用位于以下位置的 python:
/usr/lib/python2.7/
虽然您安装的模块位于此处:
/usr/local/lib/python2.7/
您需要将 wagtail 安装到第一个 python 或更改 Django 项目以使用第二个 python。
我在尝试运行时遇到了同样的问题
python manage.py migrate
,但我安装了旧版本的python,然后安装了3个,所以我使用了与此相同的命令python3 manage.py migrate