简体   繁体   English

python3 manage.py运行服务器

[英]python3 manage.py runserver

Having issues running django site with python3 manage.py runserver command. 使用python3 manage.py runserver命令运行django站点时出现问题。 I have installed django-bootstrap-ui package and added the right name to my INSTALLED_APPS but still get error below: 我已经安装了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'

Running pip list and pip show django-bootstrap-ui both show that the package has been installed in my virtual environment 运行pip list和pip show django-bootstrap-ui都显示该软件包已安装在我的虚拟环境中

I figured out the problem with the msissing package when using Python3 was that I was running the installation of my packages using pip: 我在使用Python3时发现msissing软件包的问题是我正在使用pip运行软件包的安装:

pip install django-bootstrap-ui

instead of pip3. 而不是pip3。

sudo -H pip3 install django-bootstrap-ui

While installing django I had used pip3 and as such the application starts off using the Python3 library and site-packages. 在安装django时,我使用了pip3,因此该应用程序开始使用Python3库和站点包。 Using pip to install any package will uncompress it files into the Python2 directory which is not being used by my django install (recall I used pip3 to install django). 使用pip安装任何软件包都会将其文件解压缩到Django安装未使用的Python2目录中(回想起我使用pip3来安装django)。 However, using pip3 compress the added packages into the Python3 directory which my django install uses thus can see the package. 但是,使用pip3将添加的软件包压缩到我的django安装程序使用的Python3目录中,从而可以看到该软件包。 Error eliminated :D 错误消除:D

This is due to the errors while installing your new app in settings.py and urls.py . 这是由于在settings.pyurls.py中安装新应用程序时出错。 I had the same error after editng those files to add a new app. 编辑这些文件以添加新应用后,我遇到了相同的错误。

Solution: Check 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.*

And Check settings.py 并检查settings.py

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

] ]

While you entered the app name in INSTALLED APPS list You might have Entered the wrong name 在“已安装的应用程序”列表中输入应用程序名称时,您可能输入了错误的名称

My cause of Error: I forgot to enter the comma after entering the app name 错误原因:输入应用名称后,我忘记输入逗号

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

] ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM