添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
朝气蓬勃的柿子  ·  FastAPI with Django ...·  9 分钟前    · 
聪明的啤酒  ·  Python Web Frameworks ...·  9 分钟前    · 
成熟的打火机  ·  Motivation - Django Ninja·  9 分钟前    · 
忐忑的铁板烧  ·  GitHub - ...·  9 分钟前    · 
奔跑的香烟  ·  Building APIs using ...·  9 分钟前    · 
踢足球的奔马  ·  Pushing a branch to ...·  2 月前    · 
知识渊博的冰棍  ·  python ...·  5 月前    · 
活泼的围巾  ·  FAQs and ...·  6 月前    · 
谦虚好学的花生  ·  Adobe ...·  7 月前    · 

I'm new to Django and have been going through the Mozilla Tutorial using PyCharm on a Windows machine. While doing the Djangogirls tutorial and couple of weeks ago, I learned about PythonAnywhere and had the Djangogirls working on PythonAnywhere. I got rid of that web app and now I've trying to deploy Mozilla the same way - it's working on my Windows machine and I want to migrate it to PythonAnywhere. I'm following a step using pa_autoconfigure_django.py and the command failing while running migrate database :

< Running migrate database >
Traceback (most recent call last):
  File "/home/pfuntner/pfuntner.pythonanywhere.com/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
    self.check()
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/home/pfuntner/pfuntner.pythonanywhere.com/locallibrary/urls.py", line 17, in <module>
    from django.urls import path
ImportError: cannot import name 'path'
Traceback (most recent call last):
  File "/home/pfuntner/.local/bin/pa_autoconfigure_django.py", line 56, in <module>
    main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke'))
  File "/home/pfuntner/.local/bin/pa_autoconfigure_django.py", line 43, in main
    project.run_migrate()
  File "/home/pfuntner/.local/lib/python3.6/site-packages/pythonanywhere/django_project.py", line 96, in run_migrate
    'migrate',
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[PosixPath('/home/pfuntner/.virtualenvs/pfuntner.pythonanywhere.com/bin/python'), PosixPath('/home/pfuntner/pfuntner.pythonanywhere.com/manage.py'), 'migrate']' returned
 non-zero exit status 1.
10:25 ~ $

How do I fix this?

I'm having the exact same problem trying to upload new Django Project. ..."returned non-zero exit status 1."

Would appreciate a hearing how to set up the requirements.text if this is the fix. Thanks

For me, I tried to use the newest version of Django (2.0.2?) in the local version, which caused this exact error. I had to basically through through the entire tutorial again with a new folder and install the old Django they specify (1.10.1? Something like this). Rerunning this command in Pythonanywhere's bash worked for me after that!

Thanks all. I'm using Django 2.0.2 Here is the Full Error Stack Trace.

< Running migrate database >
Traceback (most recent call last):
  File "/home/resilientstudio/resilientstudio.pythonanywhere.com/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
    self.check()
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", l
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/utils/functional.py",
 line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/site-packages/django/urls/resolvers.py", l
ine 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/lib/python3.6/importlib/__init__.py", line 126, in impor
t_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/home/resilientstudio/resilientstudio.pythonanywhere.com/base/urls.py", line 18, in <module>
    from django.urls import path
ImportError: cannot import name 'path'
Traceback (most recent call last):
  File "/home/resilientstudio/.local/bin/pa_autoconfigure_django.py", line 56, in <module>
    main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke'))
  File "/home/resilientstudio/.local/bin/pa_autoconfigure_django.py", line 43, in main
    project.run_migrate()
  File "/home/resilientstudio/.local/lib/python3.6/site-packages/pythonanywhere/django_project.py", line 96, in run_migrate
    'migrate',
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[PosixPath('/home/resilientstudio/.virtualenvs/resilientstudio.pythonanywhere.com/bin/python')
, PosixPath('/home/resilientstudio/resilientstudio.pythonanywhere.com/manage.py'), 'migrate']' returned non-zero exit status 1.
              

Just confirmed this is still an issue if you're using the djangogirls tutorial and accidentally installed django 2 instead of django 1 which they're using in the tutorial (https://tutorial.djangogirls.org/en/deploy/)

Another workaround is using the django.conf.urls module instead of the django.path module (which doesn't exist in django 1.11 installed by the pa_autoconfigure_django script).

I changed my urls.py file from

from django.contrib import admin
from django.urls import path
urlpatterns = [
    path('admin/', admin.site.urls),
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
    url(r'^admin/', admin.site.urls),

To get the site to deploy.

Note: this will require further deviation from the tutorial as you continue. This is a good workaround if you started the tutorial using django 2 and are trying to avoid restarting with an earlier version.

As of today I ran into the same problem - started with the Djangogirls tutorial and ran the autoconfigure script with the above mentioned issues. I do not reeeally want to install an earlier version of Django, so is there a description/documentation of how to link my git repo (I used Bitbucket instead but shouldn't matter) manually to my account? So that I go through all necessary steps without using the automated script? Can anyone please provide a link? Do I have to uninstall/delete the project completely again from your servers before I do so? Thanks a lot! [Sorry, Google helped: I'll try these instructions ] :-)

You're getting the error, because the Django Girls code is not for Django 2. It's not a problem with the script. The git repo that Django Girls provides will not run in Django 2.

If you want to, you can start with a git repo that is a minimal Django 1 app, use the autoconfigure script, upgrade your Django in the virtualenv and then continue with development using Django 2, but that will not necessarily follow the Django Girls tutorial.

Sorry, we have had to rate-limit your feedback sending.
Please try again in a few moments... Thanks for the feedback! Our tireless devs will get back to you soon.