I'm running django 2.0.7 on a verual envirment python3 and when i run **django-admin startproject trydjango1 . ** the following error occers can you please help me to solve this problem
Traceback (most recent call last):
File "C:\Users\TG\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\TG\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "D:\django-projects\Test1\Scripts\django-admin.exe_main.py", line 7, in
File "D:\django-projects\Test1\lib\site-packages\django\core\management_init.py", line 371, in execute_from_command_line
utility.execute()
File "D:\django-projects\Test1\lib\site-packages\django\core\management_init.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\django-projects\Test1\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\django-projects\Test1\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, **options)
File "D:\django-projects\Test1\lib\site-packages\django\core\management\commands\startproject.py", line 20, in handle
super().handle('project', project_name, target, **options)
File "D:\django-projects\Test1\lib\site-packages\django\core\management\templates.py", line 117, in handle
django.setup()
File "D:\django-projects\Test1\lib\site-packages\django_init_.py", line 16, in setup
from django.urls import set_script_prefix
File "D:\django-projects\Test1\lib\site-packages\django\urls_init_.py", line 1, in
from .base import (
File "D:\django-projects\Test1\lib\site-packages\django\urls\base.py", line 8, in
from .exceptions import NoReverseMatch, Resolver404
File "D:\django-projects\Test1\lib\site-packages\django\urls\exceptions.py", line 1, in
from django.http import Http404
File "D:\django-projects\Test1\lib\site-packages\django\http_init_.py", line 5, in
from django.http.response import (
File "D:\django-projects\Test1\lib\site-packages\django\http\response.py", line 13, in
from django.core.serializers.json import DjangoJSONEncoder
File "D:\django-projects\Test1\lib\site-packages\django\core\serializers_init_.py", line 23, in
from django.core.serializers.base import SerializerDoesNotExist
File "D:\django-projects\Test1\lib\site-packages\django\core\serializers\base.py", line 6, in
from django.db import models
File "D:\django-projects\Test1\lib\site-packages\django\db\models_init_.py", line 3, in
from django.db.models.aggregates import * # NOQA
File "D:\django-projects\Test1\lib\site-packages\django\db\models\aggregates.py", line 5, in
from django.db.models.expressions import Case, Func, Star, When
File "D:\django-projects\Test1\lib\site-packages\django\db\models\expressions.py", line 486, in
class TemporalSubtraction(CombinedExpression):
File "D:\django-projects\Test1\lib\site-packages\django\db\models\expressions.py", line 487, in TemporalSubtraction
output_field = fields.DurationField()
File "D:\django-projects\Test1\lib\site-packages\django\db\models\fields_init_.py", line 155, in init
if isinstance(choices, collections.Iterator):
AttributeError: module 'collections' has no attribute 'Iterator'
You should try different python or/and django version, because both are not compatible with each other.
Try upgrading Django to 2.2.28 version, or run project under python 3.6 (or even lower ver).
I think you should install a newer version of django. It could be that some packages in the version of django you are using are not supported by python 3. I suggest you upgrade to django 3+
Related
I am trying to start a django project using the django-admin startproject but it keeps bringing this error:
Traceback (most recent call last):
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\Scripts\django-admin.exe\__main__.py", line 7, in <module>
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, **options)
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\startproject.py", line 20, in handle
super().handle('project', project_name, target, **options)
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\templates.py", line 117, in handle
django.setup()
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 16, in setup
from django.urls import set_script_prefix
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\__init__.py", line 1, in <module>
from .base import (
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\base.py", line 8, in <module>
from .exceptions import NoReverseMatch, Resolver404
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
from django.http import Http404
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\http\__init__.py", line 5, in <module>
from django.http.response import (
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\http\response.py", line 13, in <module>
from django.core.serializers.json import DjangoJSONEncoder
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
from django.db import models
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
from django.db.models.aggregates import * # NOQA
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
from django.db.models.expressions import Case, Func, Star, When
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\expressions.py", line 486, in <module>
class TemporalSubtraction(CombinedExpression):
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\expressions.py", line 487, in TemporalSubtraction
output_field = fields.DurationField()
File "C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\fields\__init__.py", line 155, in __init__
if isinstance(choices, collections.Iterator):
AttributeError: module 'collections' has no attribute 'Iterator'
How can i fix this? At first, I created a virtual environment where I installed django and created a project using the same command and I did not get the error, but when I tried to run the python manage.py runserver command, I got this error:
(venv) C:\Users\GAbraham.AECIGROUP\DEV\trydjango\venv>python manage.py runserver
C:\Users\GAbraham.AECIGROUP\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\\Users\\GAbraham.AECIGROUP\\DEV\\trydjango\\venv\\manage.py': [Errno 2] No such file or directory
You should be in the project's root folder in order to run the command python manage.py runserver
According to your error, you are somewhere in venv folder.
You should be in the trydjango folder (according to the screenshots) and then run the above command.
Hope this helps!
New to django… Since a month i'm trying to follow this tutorial without success. When i syncdb i get following error:
(virt-inplaceedit)Mac:testing manuelstrasser$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/__init__.py", line 1, in <module>
from sorl.thumbnail.fields import ImageField
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/fields.py", line 6, in <module>
from sorl.thumbnail import default
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/default.py", line 3, in <module>
from sorl.thumbnail.helpers import get_module_class
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/helpers.py", line 5, in <module>
from django.utils import simplejson
ImportError: cannot import name simplejson
I installed simplejson but still same error. Anyone haveing experiences with this tutorial? I did everything exactly as per description…
django.utils.simplejson is deprecated in django 1.7.
Looks like you use old version of the sorl-thumbnail. Current version of sorl-thumbnail supports django 1.7 so try to update this library.
I'm trying to convert a django project into a desktop app.
I've downloaded the developer version of pyinstaller: github/pyinstaller/pyinstaller.
hookutils.py is modified as stated here: http://www.pyinstaller.org/ticket/754 in order for pyinstaller to find my root directory: Django root directory c:\Workspace\mysite\mysite
The project I'm trying to compile is the initial project gotten after running: django-admin.py startproject mysite, so no apps created yet.
When following the steps as described on pyinstaller (http://www.pyinstaller.org/wiki/Recipe/DjangoApplication) I get some errors when trying to run the server (
.\dist\mysite\mysite.exe runserver localhost:8080):
c:\Workspace\compiled>.\dist\mysite\mysite.exe runserver
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management", line 453, in execute_from_command_line
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management", line 392, in execute
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management", line 263, in fetch_command
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management", line 109, in get_commands
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.conf", line 53, in __getattr__
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.conf", line 49, in _setup
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.conf", line 71, in _configure_logging
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.utils.log", line 6, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.views.debug", line 11, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.http", line 1, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.http.cookie", line 5, in <module>
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.utils.six", line 84, in __get__
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.utils.six", line 103, in _resolve
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.utils.six", line 74, in _import_module
ImportError: No module named Cookie
If I then import Cookie in manage.py then, another error appears:
Unhandled exception in thread started by <bound method Command.inner_run of <django.core.management.commands.runserver.Command object at 0x02D86CF0>>
Traceback (most recent call last):
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management.commands.runserver", line 92, in inner_run
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management.base", line 280, in validate
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.core.management.validation", line 35, in get_validation_errors
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.db.models.loading", line 166, in get_app_errors
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.db.models.loading", line 75, in _populate
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.db.models.loading", line 96, in load_app
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.utils.importlib", line 35, in import_module
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.contrib.auth.models", line 18, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.contrib.auth.hashers", line 8, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.test", line 6, in <module>
File "C:\Workspace\pyinstaller-develop\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "c:\Workspace\compiled\build\mysite\out00-PYZ.pyz\django.test.testcases", line 35, in <module>
ImportError: cannot import name _doctest
I have tried to import doctest, but it doesn't help.
Using python 2.7.4 and django 1.5.1
Edit:
So by adding django.test and HTMLParser to the manage.py, I got it to work:
import os
import sys
import Cookie
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "OTA.settings")
from django.core.management import execute_from_command_line
import django.test
import HTMLParser
execute_from_command_line(sys.argv)
Django imports local doctest module. Maybe try import django.test?
Also from the PyInstaller docs about including additional modules:
You can give additional files on the PyInstaller command line.
You can give additional import paths on the command line.
You can edit the myscript.spec file that PyInstaller writes the first time you run
it for your script. In the spec file you can tell PyInstaller about code and data files that are unique to your script.
You can write "hook" files that inform PyInstaller of hidden imports. If you "hook" imports for a package that other users might also use, you can contribute your hook file to PyInstaller.
I also recommend py2exe, if PyInstaller won't meet Your needs.
I am going through the docs of http://django-blog-zinnia.com/documentation/getting-started/install/
and when I syncdb I get this error, tagging is in my installed apps, can someone help me?
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/base.py", line 231, in execute
self.validate()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_blog_zinnia-0.12.dev-py2.7.egg/zinnia/models/__init__.py", line 5, in <module>
from zinnia.models.entry import Entry
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_blog_zinnia-0.12.dev-py2.7.egg/zinnia/models/entry.py", line 22, in <module>
from tagging.fields import TagField
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/tagging-0.2.1-py2.7.egg/tagging/fields.py", line 10, in <module>
from tagging.models import Tag
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/tagging-0.2.1-py2.7.egg/tagging/models.py", line 9, in <module>
from tagging.managers import TagManager, TaggedItemManager
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/tagging-0.2.1-py2.7.egg/tagging/managers.py", line 6, in <module>
from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup
You seem to be using an old version of django-tagging (your issue is discussed here!) which itself depends on an old version of Django.
Upgrade django-tagging to the latest version; 0.3.1 seems to be the latest release, but the project hasn't seen any activity since 2010 -- I don't know if it's still alive or just very stable.
my django app run with mysql, but when i try with mongodb then show thie error
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/home/abdullah/django-trunk/django/core/management/__init__.py", line 442, in execute_manager
utility.execute()
File "/home/abdullah/django-trunk/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/abdullah/django-trunk/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/abdullah/django-trunk/django/core/management/base.py", line 209, in execute
translation.activate('en-us')
File "/home/abdullah/django-trunk/django/utils/translation/__init__.py", line 106, in activate
return _trans.activate(language)
File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 191, in activate
_active.value = translation(language)
File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 180, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 157, in _fetch
app = import_module(appname)
File "/home/abdullah/django-trunk/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/abdullah/django-trunk/django/contrib/admin/__init__.py", line 3, in <module>
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/home/abdullah/django-trunk/django/contrib/admin/helpers.py", line 2, in <module>
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
File "/home/abdullah/django-trunk/django/contrib/admin/util.py", line 1, in <module>
from django.db import models
File "/home/abdullah/django-trunk/django/db/__init__.py", line 27, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/home/abdullah/django-trunk/django/db/utils.py", line 82, in __getitem__
conn = backend.DatabaseWrapper(db, alias)
File "/usr/local/lib/python2.6/dist-packages/django_mongodb_engine-0.4.0-py2.6.egg/django_mongodb_engine/base.py", line 87, in __init__
self.ops = DatabaseOperations(self)
File "/usr/local/lib/python2.6/dist-packages/djangotoolbox-0.9.2-py2.6.egg/djangotoolbox/db/base.py", line 28, in __init__
super(NonrelDatabaseOperations, self).__init__()
TypeError: __init__() takes exactly 2 arguments (1 given)
** I have installed all necessary module installed, but when i want to runserver then show this message
I managed to fix the same error by using these packages on github:
https://github.com/django-nonrel/django-nonrel
https://github.com/django-nonrel/djangotoolbox
instead of the ones recommended on Django-Mongodb's setup page. Also, make sure to use the master branch of each, so as to not run into compatibility problems. If you're using pip, you can either pip install each of the following lines separately, or put them into your version of a requirements.txt file for your project:
git+https://github.com/django-nonrel/django-nonrel#master
git+https://github.com/django-nonrel/djangotoolbox#master
git+https://github.com/django-nonrel/mongodb-engine#master
And then run
pip install -r requirements.txt