python3 manage.py runserver

时间:2016-01-10 01:03:39

标签: python django

使用python3 manage.py runserver命令运行django站点时出现问题。我已经安装了django-bootstrap-ui包并将正确的名称添加到我的INSTALLED_APPS中,但仍然会收到以下错误:

(django_env)my_machine@my_pc:~/srv_django/etransphere$ python3 manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f14d33458c8>
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/usr/local/lib/python3.4/dist-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'bootstrap_ui'

运行pip list和pip show django-bootstrap-ui都显示该软件包已安装在我的虚拟环境中

2 个答案:

答案 0 :(得分:1)

我在使用Python3时发现msissing包的问题是我使用pip运行我的软件包的安装:

pip install django-bootstrap-ui

而不是pip3。

sudo -H pip3 install django-bootstrap-ui

安装django时我使用了pip3,因此应用程序开始使用Python3库和site-packages。使用pip安装任何软件包都会将文件解压缩到我的django安装没有使用的Python2目录中(回想一下我使用pip3来安装django)。但是,使用pip3将添加的包压缩到我的django安装使用的Python3目录中,从而可以看到包。消除错误:D

答案 1 :(得分:0)

这是因为在 settings.py urls.py 中安装新应用时出错。在编辑这些文件以添加新应用程序后,我遇到了同样的错误。

<强>解决方案:  检查 urls.py

urlpatterns = [
url(r'^admin/', admin.site.urls),
*#this may be the place where you entered the app url but created an syntax error.*

并检查 settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

当您在INSTALLED APPS列表中输入应用名称时,您可能输入了错误的名称

我的错误原因:我输入应用名称后忘记输入逗号

INSTALLED_APPS = [
'appName'  <<<<<<< 
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',