3

Having issues running django site with python3 manage.py runserver command. I have installed django-bootstrap-ui package and added the right name to my INSTALLED_APPS but still get error below:

(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

10
  • I have multiple Python version installed on my machine. All django packages I install give the same error. Trackback shows python path as "/usr/lib/python3" but all the packages are found in python2.7 directory. I think I need to point WSGI or django to use Python 2.7 as default Jan 10, 2016 at 2:33
  • So it looks like the python3 command may not be pointing to your virtualenv. Type which python3 to confirm this. Also run which python -- does that point to your virtualenv?
    – Eli Rose
    Jan 10, 2016 at 2:41
  • Also, are you trying to use Python 3 or 2? You invoke the command with python3 ..., but your last comment says 2.7
    – Eli Rose
    Jan 10, 2016 at 2:43
  • I invoke the runserver command with python2.7 but get an error. If I however invoke it with python3 that error does not occur. But my site packages do not load with python3 Jan 10, 2016 at 2:48
  • The code block above shows you executing python3 manage.py runserver and getting an error -- that seems to contradict what you just said. Did you write down the wrong one by mistake? (Also, if you don't mind, was was the output of which python and which python3?)
    – Eli Rose
    Jan 10, 2016 at 2:51

2 Answers 2

1

I figured out the problem with the msissing package when using Python3 was that I was running the installation of my packages using pip:

pip install django-bootstrap-ui

instead of 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. 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). However, using pip3 compress the added packages into the Python3 directory which my django install uses thus can see the package. Error eliminated :D

0

This is due to the errors while installing your new app in settings.py and urls.py. I had the same error after editng those files to add a new app.

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

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',

]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.