I am getting the following error while runserver command in Django. I am using wagtail CMS. Could someone help me with this, please ?
C:\Users\MAFON\Desktop\mafonglobal>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 62, in execute
super(Command, self).execute(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 101, in handle
self.run(**options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 110, in run
autoreload.main(self.inner_run, None, options)
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 332, in main
reloader(wrapped_main_func, args, kwargs)
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 303, in python_reloader
exit_code = restart_with_reloader()
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 289, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ)
File "C:\Python27\lib\subprocess.py", line 168, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
TypeError: environment can only contain strings
This was a Django bug introduced in Django 1.11:
https://code.djangoproject.com/ticket/28174
This is now fixed in Django 1.11.4, so upgrading to the latest Django should solve this. However, I'd strongly recommend upgrading to Python 3 (which will also avoid this issue) - Python 2.7 is very much end-of-line now, and support for it will be dropped in Django 2.0 (due at the end of this year).
Related
I am currently working with a project that requires import an excel file into Django database. I googled it and found out that django-import-export package is exactly what I want.
However, when I import "import_export" into my "settings.py" or "from import_export.admin import ImportExportModelAdmin" into my "admin.py", the error appears although I have successfully installed this package. I have also followed the tutorial here, but the result is still the same.
Is there any way to solve this problem or any suggestions? Could you please help me? Thanks in advance!
Here is the code from a tutorial on youtube that I used for testing:
/*admin.py*/
from django.contrib import admin
# Register your models here.
from .models import *
from import_export.admin import ImportExportModelAdmin
#admin.register(Laptop, Desktop, Mobile)
class ViewAdmin(ImportExportModelAdmin):
pass
/*settings.py*/
INSTALLED_APPS = [
...
'import_export',
]
/*After running python manage.py runserver */
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "manage.py", line 24, in <module>
main()
File "manage.py", line 20, in main
execute_from_command_line(sys.argv)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 299, in run
self.run_loop()
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 305, in run_loop
next(ticker)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\django\utils\autoreload.py", line 118, in iter_modules_and_files
if module.__name__ == '__main__':
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\py\_apipkg.py", line 171, in __getattribute__
return getattr(getmod(), name)
File "C:\FWTools\WinPython-201702\python-3.6.2\lib\site-packages\py\_error.py", line 44, in __getattr__
raise AttributeError(name)
AttributeError: __name__
I suggest you get the example application working first.
Clone repo from github
Install dependencies into a virtual env (e.g. pip install -r requirements/test.txt)
Follow these instructions to install and load the example app.
Once you have the example application running, you have the basis for developing your own.
For some reasons, I had to reinstall Python on my desktop. Since then, my django applications are not working. I can create one, but as soon as I import a package anywhere in the application, I can't run python manage.py runserver
I can run another python script, I can start Jupyter Notebooks (and import the exact same packages in them). I also tried to create new projects with the "new" python installed, as soon as I add import pandas (or any other packages except django), I have the error.
The error message is quite long :
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 585, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 570, in start_django
reloader.run(django_main_thread)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 288, in run
self.run_loop()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 294, in run_loop
next(ticker)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 334, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 350, in snapshot_files
for file in self.watched_files():
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 249, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 116, in iter_modules_and_files
if module.__name__ == '__main__':
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\py\_
apipkg.py", line 171, in __getattribute__
return getattr(getmod(), name)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\py\_
error.py", line 44, in __getattr__
raise AttributeError(name)
AttributeError: __name__
Got this annoying error after aborting an IDE-refactoring.
I suggest the following to reproduce the problem:
Revert git changes.
Make sure there are no cyclic imports in your code.
Reinstall virtual environment.
Unfortunately the error was still there in my case. So I knew the problem must be with python. And indeed:
Reinstalling python 3.7 solved the problem.
Did you pip install django?
I think when you reinstalled Python you didn't installed packaged like Django
Uninstall the current Django package and install Django 2.1.5
Use this command on windows:
pip install --user django==2.1.5
I want to install djangocms_table plugin.My current Django cms version is 3.5.2
I followed the below steps to do the same.
1.pip install djangocms_table
2.Added 'djangocms_table' to INSTALLED_APPS
3.manage.py migrate djangocms_table
After I ran migrate command got the below exception.
System check identified some issues:
WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
Traceback (most recent call last):
File "/host/lendingstream/src/web/ConsumerUI/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 25, in handle
call_command("migrate", **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 182, in build_graph
self.load_disk()
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 123, in load_disk
"creating Django migrations." % app_config.label
django.db.migrations.loader.BadMigrationError: Migrated app 'djangocms_table' contains South migrations. Make sure all numbered South migrations are deleted prior to creating Django migrations.
I have installed django-jenkins in following environment
coverage (4.0.1)
Django (1.8)
pep8 (1.6.2)
django-jenkins (0.17.0)
pyflakes (1.0.0)
and I when I try this
python manage.py jenkins --enable-coverage
I get this error
Destroying test database for alias 'default'...
Storing coverage info...
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/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(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/test.py", line 74, 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_jenkins/management/commands/jenkins.py", line 161, in handle
coverage.save(tested_locations, options)
File "/usr/local/lib/python2.7/dist-packages/django_jenkins/tasks/with_coverage.py", line 33, in save
self.coverage.stop()
AttributeError: 'Coverage' object has no attribute '_harvest_data'
Any ideas ? I followed this manual exactly.
I found out the django-jenkins uses Coverage and in newest version of coverage the method _harvest_data has changed to get_data but in the final official release of django-jenkins it has not been applied so I switched to their latest git version and it solved.
I´m having a issue when I ran "python manage.py rebuild_index" in my app supported by haystack and elasticsearch.
Python 2.7
Django version 1.6.2
Haystack 2.1.0
Elasticsearch 1.0
Please see the error that is appearing:
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 399, in > execute_from_command_line
utility.execute()
File "/usr/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/lib/python2.7/site-packages/django/core/management/base.py", line 242, in >run_from_argv
self.execute(*args, **options.dict)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/haystack/management/commands/rebuild_index.py", line 15, in handle
call_command('clear_index', **options)
File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 159, in call_command
return klass.execute(*args, **defaults)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/haystack/management/commands/clear_index.py", line 48, in handle
backend = connections[backend_name].get_backend()
File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 98, in getitem
self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 51, in load_backend
return import_class(full_backend_path)
File "/usr/lib/python2.7/site-packages/haystack/utils/loading.py", line 18, in import_class
module_itself = importlib.import_module(module_path)
File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
import(name)
File "/usr/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 21, in
raise MissingDependency("The 'elasticsearch' backend requires the installation of 'requests'.")
haystack.exceptions.MissingDependency: The 'elasticsearch' backend requires the installation of 'requests'.
I've installed all the packages needed to run those apps however is asking about requests, What is it about?
just do
pip install pyelasticsearch
If you just install requests module through pip this error should go away.