How can I create a project on Django using Elementary os? - python

I'm having troubles when I try to create my project on Django.
Error message:
django-admin.py startproject car
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/startproject.py", line 2, in <module>
from django.core.management.templates import TemplateCommand
File "/usr/local/lib/python2.7/site-packages/django/core/management/templates.py", line 20, in <module>
from django.template import Template, Context
File "/usr/local/lib/python2.7/site-packages/django/template/__init__.py", line 53, in <module>
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 12, in <module>
from django.utils.text import (smart_split, unescape_string_literal,
File "/usr/local/lib/python2.7/site-packages/django/utils/text.py", line 6, in <module>
from gzip import GzipFile
File "/usr/local/lib/python2.7/gzip.py", line 9, in <module>
import zlib
ImportError: No module named zlib
(I already have Python 2.7 and Django 1.5.1 installed)

You should read your errors more carefuly.
ImportError: No module named zlib

Related

Getting Error While running manage.py ...import Error cannot import name backend

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/devbase/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/devbase/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/devbase/env/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/devbase/env/local/lib/python2.7/site-packages/django/apps/registry .py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/devbase/env/local/lib/python2.7/site-packages/django/apps/config.p y", line 94, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/devbase/env/local/lib/python2.7/site-packages/djorm_pgtrgm/__init_ _.py", line 1, in <module>
from django.db import backend
ImportError: cannot import name backend
It looks like you are using djorm_pgtrgm. It hasn't been updated for two years, so you can't expect it to work with recent versions of Django.
This merged pull request suggests that the import error has been fixed in the GitHub repo, but there hasn't been a release since then. You could try installing from source, but you should think about whether you want to use an unmaintained package in your project.

Django gmane Syntax error

Traceback (most recent call last):
File "manage.py", line 10, in <module> execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 324, in execute
django.setup()
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/social/__init__.py", line 5, in <module>
from .fsong import *
File "/Library/Python/2.7/site-packages/social/fsong.py", line 1, in <module>
import gmane as g, networkx as x, pylab as p, numpy as n, os
File "/Library/Python/2.7/site-packages/gmane/__init__.py", line 26, in <module>
from .networkEvolution import NetworkEvolution
File "/Library/Python/2.7/site-packages/gmane/networkEvolution.py", line 9, in <module>
from .pca import *
File "/Library/Python/2.7/site-packages/gmane/pca.py", line 79
def __init__(self,*metrics,final_dimensions=2,draw=False):
SyntaxError: invalid syntax
I have installed django using pip and trying to run python manage.py migrate. I am facing the above error. Any one have faced this before? I am using OSX and python version is 2.7.10, Django version 1.9

ImportError: cannot import name AccessMixin

I'm trying to run the following package from github - https://github.com/rollstudio/django-admin2-sb
But I'm getting the following traceback
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/djadmin2/__init__.py", line 13, in <module>
from . import core
File "/usr/local/lib/python2.7/dist-packages/djadmin2/core.py", line 14, in <module>
from . import apiviews
File "/usr/local/lib/python2.7/dist-packages/djadmin2/apiviews.py", line 12, in <module>
from .viewmixins import Admin2Mixin
File "/usr/local/lib/python2.7/dist-packages/djadmin2/viewmixins.py", line 15, in <module>
from braces.views import AccessMixin
ImportError: cannot import name AccessMixin
braces is installed I can see it in the following location -
/usr/local/lib/python2.7/dist-packages/braces/views
_access.py contains the class class AccessMixin(object):
so why doesn't it import?
In django-braces 1.3, views exported AccessMixin but in django-braces 1.4 this was moved to views._access and not exported in views.
This should be fixed in versions>1.4
Another workaround for this error is to downgrade django-braces to version 1.3.1.
Checkout this github issue: https://github.com/pydanny/django-admin2/issues/396

Django app engine cannot import name old_dev_appserver

I am trying to use django in appengine. I have followed the installation documentation and setup the project. But ./manage.py runserver command is generating error.
Traceback is,
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 263, in fetch_command
app_name = get_commands()[subcommand]
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 109, in get_commands
apps = settings.INSTALLED_APPS
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 132, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/salman/projects/appengine/banglapy/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/salman/projects/appengine/banglapy/banglapy/settings.py", line 6, in <module>
from djangoappengine.settings_base import *
File "/home/salman/projects/appengine/banglapy/djangoappengine/settings_base.py", line 8, in <module>
from djangoappengine.utils import on_production_server, have_appserver
File "/home/salman/projects/appengine/banglapy/djangoappengine/utils.py", line 24, in <module>
"Error was: %s" % e)
Exception: Could not get appid. Is your app.yaml file missing? Error was: cannot import name old_dev_appserver
how can I resolve this issue?
Google removed the old dev_appserver from the SDK in version 1.9.17. There is an issue on the djangoappengine project about it as well.
https://github.com/django-nonrel/djangoappengine/issues/95

Running Django development server

I'm trying to create and run a project.
I used the following article:
https://docs.djangoproject.com/en/dev/intro/tutorial01/?from=olddocs
When I'm running the following command
C:\django\mysite>python manage.py runserver
This error shows up:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 4, in <module>
from django.core.management.commands.runserver import BaseRunserverCommand
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 8, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 10, in <module>
from django import http
File "C:\Python27\lib\site-packages\django\http\__init__.py", line 117, in <module>
from django.core import signing
ImportError: cannot import name signing
Here is what I would do.
Try to use virtualenv.
there might be some old python modules that mess up your django for some reason.
So use virtualenv to create a fresh python.
and install django with pip install.
if it solves the problem its definetely your system python that is messing things up a little bit.

Categories