No translation file found for domain 'django' - python

Environment :
python 2.7.10
django 1.8.6(copied from site-package folder)
I copied the django distribute into my project folder.
Thinking it will work well
It works perfectly in one of my machine, but throw an error below in another one
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "cmdb_lib/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "cmdb_lib/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "cmdb_lib/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "cmdb_lib/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "cmdb_lib/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "cmdb_lib/django/core/management/base.py", line 458, in execute
translation.activate(saved_locale)
File "cmdb_lib/django/utils/translation/__init__.py", line 146, in activate
return _trans.activate(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 222, in activate
_active.value = translation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 206, in translation
_translations[language] = DjangoTranslation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 115, in __init__
self._init_translation_catalog()
File "cmdb_lib/django/utils/translation/trans_real.py", line 153, in _init_translation_catalog
translation = self._new_gnu_trans(localedir, use_null_fallback)
File "cmdb_lib/django/utils/translation/trans_real.py", line 136, in _new_gnu_trans
fallback=use_null_fallback)
File "/usr/local/lib/python2.7/gettext.py", line 472, in translation
raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: u'django'
But in my settings.py I set LANGUAGE_CODE = 'en-us' as default!
How could this throw an error?
I tried to pip install django, problem solved ,but I still want to include the django package in my project.
How can I achieve this?

I think I got the solution , my .gitignorefile ignored the .mo file , I added it and everything 's OK now
If you are using git, check your .gitignore file and comment*.mo
add the missing .mofile ,and things will be good

Related

After deleting my database and trying to apply a new migrations i get this errors that say django.db.migrations.exceptions.NodeNotFoundError

Am trying to apply a migration to a new database but I keep getting this error, I have deleted all migration files in my old database and also files in the apps. when I tried applying migrations to a new database or running python manage.py runserver then I get this error..? I wonder what might be the problem. am using Django 3.1.1
E:\All django project\Real-Estate-Django-Web-App-master>manage.py migrate
Traceback (most recent call last):
File "E:\All django project\Real-Estate-Django-Web-App-master\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 92, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python38\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 255, in build_graph
self.graph.validate_consistency()
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 58, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_user_following dependencies reference nonexistent parent node ('account', '0003_contact')
Well! I was finally able to fix this problem by first uninstalling Django on my virtual env and then redo the installation, but the problem had still persisted, so I just followed my intuition by deleting the whole virtual env, I did the installation of virtualenv and then installed Django and it worked, perfectly. Thank you to all who had tried to help, I really appreciated your answers.
The auth.0013_user_following migration requires the 0003_contact migration which is missing.
Try removing all migrations from all apps and set a new database.
Based on the solution provided by Abubakari UmarblacKrussain Uma, I noticed that packages linked to my virtual environment file were missing/corrupted. When I checked it against my requirements.text file, I noticed that the Django package was replaced by django 2.2.27 (django lowercase), and an entry -jango 3.1.3 was added. I manually edited the requirements.txt file to remove the -jango 3.1.3 entry and replace the django 2.2.27 with Django 3.1.3 and reloaded the virtual environment from requirements.txt. This resolved the error. For good measure I re-generated the requirements.txt file for the virtual environment.

Why do I get the error that the 'split' attribute is missing when I run runmodwsgi?

I am in the process of moving the django page to a new server. Due to complications in the apache server configuration, I used mod_wsgi-express integrated into virtualenv python. According to the instructions found on this page: https://pypi.org/project/mod-wsgi/#description , I added mod_wsgi.server to installed Django applications and run the command python manage.py runmodwsgi. Unfortunately, in response I get an error which pastes below. I would be very grateful for any help and explanation why this problem appeared.
Traceback (most recent call last):
File "SAGI-B/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/mod_wsgi/server/management/commands/runmodwsgi.py", line 71, in handle
fields = wsgi_application.split('.')
AttributeError: 'NoneType' object has no attribute 'split'
The Django version I use is 1.10.7 (I know, I should upgrade - I'm in the process). In the settings.py configuration file I didn't find the line with WSGI_APPLICATION = 'xyz.wsgi.application'. Could this be the cause of the error?
The absence of a line with WSGI_APPLICATION = ... in the settings.py file was the reason for the failure.

Fail with django app on azure

I'm trying to develop and deploy django app on azure web apps.
While following the tutorial on azure website, after cloning the basic project to my local machine (using git) and creating the virtual environment, I'm trying to run the createsuperuser commend, and getting this error:
C:\Users\tutzy\Desktop\newtest\amir1>env\scripts\python manage.py createsuperuser
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 52, in execute
return super(Command, self).execute(*args, **options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 413, in execute
translation.activate(saved_locale)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\__init__.py", line 154, in activate
return _trans.activate(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 216, in activate
_active.value = translation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 205, in translation
_translations[language] = DjangoTranslation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 118, in __init__
raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
IOError: No translation files found for default language en-us.
It seems that your issue was similar with the other SO thread No translation file found for domain 'django' if you clone the Azure offical sample for Django like this. There is a *.mo line at the 49th line of .gitignore file. Please try to add the missing .mo file and do the createsupersuer operation again.
Hope it helps.

"abort: The system cannot find the file specified" in Mercurial

I have a large (~700MB) Mercurial repository. I can clone the repo fine without updating (and also it's totally browsable on Bitbucket, where it's hosted) but I can't update the working directory to the latest changeset because I get the following error:
... lot of getting [path] lines here
getting path/to/some/file.ext
abort: The system cannot find the file specified
[command returned code 255 Wed Jun 24 00:51:37 2015]
The last file before the error actually exists in the repo (it's visible in Bitbucket too).
I thought the issue was because of too long paths, but even cloning to a drive root yields the same. Paths could still be too long but "path/to/some/file.ext" is just 60 characters.
Running the command with traceback yields this:
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 160, in _runcatch
File "mercurial\dispatch.pyo", line 885, in _dispatch
File "mercurial\dispatch.pyo", line 646, in runcommand
File "mercurial\dispatch.pyo", line 976, in _runcommand
File "mercurial\dispatch.pyo", line 947, in checkargs
File "mercurial\dispatch.pyo", line 882, in <lambda>
File "mercurial\util.pyo", line 716, in check
File "mercurial\extensions.pyo", line 168, in closure
File "mercurial\util.pyo", line 716, in check
File "hgext\mq.pyo", line 3505, in mqcommand
File "mercurial\util.pyo", line 716, in check
File "mercurial\commands.pyo", line 6402, in update
File "mercurial\hg.pyo", line 535, in clean
File "mercurial\hg.pyo", line 520, in updaterepo
File "mercurial\merge.pyo", line 1140, in update
File "mercurial\merge.pyo", line 772, in applyupdates
File "mercurial\subrepo.pyo", line 246, in submerge
File "mercurial\context.pyo", line 252, in sub
File "mercurial\subrepo.pyo", line 341, in subrepo
File "mercurial\subrepo.pyo", line 1206, in __init__
File "mercurial\subrepo.pyo", line 1216, in _ensuregit
File "mercurial\subrepo.pyo", line 1294, in _gitnodir
File "subprocess.pyo", line 710, in __init__
File "subprocess.pyo", line 958, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
The repo has git subrepos (these are public repos on GitHub). And hg-git works for me otherwise, I'm able to pull from and push to git repos from hg.
Anybody with an idea how to solve this?
Solved the issue: Lazy Badger pointed into the right direction. The issue was that the path to the git executable wasn't added to my PATH environment variable.
Adding C:\Program Files (x86)\Git\bin\ (or where you have git.exe on your system) to PATH with Rapid Environment Editor (I needed to use this tool as my PATH was over 1024 chars, so using setx wasn't working) to the System variables solved it.

django and python manage.py runserver execution error

When I execute python manage.py runserver command for my django_test projects I get following error:
System check identified no issues (0 silenced).
June 14, 2015 - 20:43:03
Django version 1.8.2, using settings 'django_test.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
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 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 49, in execute
super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in handle
self.run(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 97, in run
autoreload.main(self.inner_run, None, options)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 323, in main
reloader(wrapped_main_func, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 289, in python_reloader
reloader_thread()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 265, in reloader_thread
change = fn()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 190, in inotify_code_changed
update_watch()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 184, in update_watch
wm.add_watch(path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1903, in add_watch
exclude_filter)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1822, in __add_watch
wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 150, in inotify_add_watch
return self._inotify_add_watch(fd, pathname, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 245, in _inotify_add_watch
return self._libc.inotify_add_watch(fd, pathname, mask)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected CString instance instead of c_char_Array_64
I have never had this problem before and my code always worked fine until I moved the project from one laptop to the other and can not execute it here.
Originaly, it worked fine but the system crashed and it is first time when I am trying to run the code on the new machine. I use virtualenv so I would expect everything to work smoothly but it does not ...
Is it a problem with python itself ?
It looks like you're running against the system version of python on the new laptop, rather than the virtualenv, so it is probably a different version. You can check this by looking at the version of Python on the virtualenv in the old laptop and the new laptop with python --version - I've seen this error happen in this case to people before.
Your best bet is to create a new virtualenv on the new laptop, and reinstall your packages (hopefully, you have a requirements.txt handy). If you need the same version of Python on the new laptop, you'll have to explore getting that version installed on your new laptop (do not overwrite the system version!), and pointing your virtualenv to the install. Good luck.

Categories