Forums

pa_autoconfigure_django.py, No module named 'cv2', 'migrate']' returned non-zero exit status 1.

Hi everyone, I really struggling. Any help would be appreciated.

I am running pa_autoconfigure_django.py and I get an error code related to cv2 and the migrate step. I have looked through the forum but can't find anything relevant. Please forgive me if I am being silly.

I have used the link to my github in the first line.

$ pa_autoconfigure_django.py --python=3.9 https://github.com/<your-github-username>/my-first-blog.git

< Running API sanity checks >
   \
    ~<:>>>>>>>>>
Cloning into '/home/twgenie/twgenie.pythonanywhere.com'...
remote: Enumerating objects: 85, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 85 (delta 15), reused 80 (delta 10), pack-reused 0
Unpacking objects: 100% (85/85), 11.75 MiB | 4.38 MiB/s, done.
Updating files: 100% (99/99), done.

< Creating virtualenv with Python3.9 >
   \
    ~<:>>>>>>>>>
created virtual environment CPython3.9.13.final.0-64 in 17695ms
  creator CPython3Posix(dest=/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/twgenie/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/preactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/postactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/get_env_details

< Pip installing django (this may take a couple of minutes) >
   \
    ~<:>>>>>>>>>
Looking in links: /usr/share/pip-wheels
Collecting django
  Downloading Django-4.2.6-py3-none-any.whl (8.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 14.6 MB/s eta 0:00:00
Collecting sqlparse>=0.3.1
  Downloading sqlparse-0.4.4-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.2/41.2 kB 708.2 kB/s eta 0:00:00
Collecting asgiref<4,>=3.6.0
  Downloading asgiref-3.7.2-py3-none-any.whl (24 kB)
Collecting typing-extensions>=4
  Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Installing collected packages: typing-extensions, sqlparse, asgiref, django
Successfully installed asgiref-3.7.2 django-4.2.6 sqlparse-0.4.4 typing-extensions-4.8.0

< Creating web app via API >
   \
    ~<:>>>>>>>>>

< Adding static files mappings for /static/ and /media/ >
   \
    ~<:>>>>>>>>>

< Updating wsgi file at /var/www/twgenie_pythonanywhere_com_wsgi.py >
   \
    ~<:>>>>>>>>>

< Updating settings.py >
   \
    ~<:>>>>>>>>>

< Running collectstatic >
   \
    ~<:>>>>>>>>>

134 static files copied to '/home/twgenie/twgenie.pythonanywhere.com/static'.

< Running migrate database >
   \
    ~<:>>>>>>>>>
Traceback (most recent call last):
  File "/home/twgenie/twgenie.pythonanywhere.com/manage.py", line 22, in <module>
    main()
  File "/home/twgenie/twgenie.pythonanywhere.com/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 100, in handle
    self.check(databases=[database])
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/management/base.py", line 485, in check
    all_issues = checks.run_checks(
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/urls/resolvers.py", line 494, in check
    for pattern in self.url_patterns:
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/twgenie/twgenie.pythonanywhere.com/pep_genie/urls.py", line 24, in <module>
    path('', include('app.urls'))
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.9/site-packages/django/urls/conf.py", line 38, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/twgenie/twgenie.pythonanywhere.com/app/urls.py", line 2, in <module>
    from . import views
  File "/home/twgenie/twgenie.pythonanywhere.com/app/views.py", line 5, in <module>
    from .pytools import *
  File "/home/twgenie/twgenie.pythonanywhere.com/app/pytools.py", line 2, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'
Traceback (most recent call last):
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 49, in <module>
    main(
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 40, in main
    project.run_migrate()
  File "/home/twgenie/.local/lib/python3.9/site-packages/pythonanywhere/django_project.py", line 132, in run_migrate
    subprocess.check_call([
  File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/python', '/home/twgenie/twgenie.pythonanywhere.com/manage.py', 'migrate']' returned non-zero exit status 1.
19:47 ~ $ pa_autoconfigure_django.py --python=3.8 https://github.com/tombiocode2/pep_genie.git

< Running API sanity checks >
   \
    ~<:>>>>>>>>>
Traceback (most recent call last):
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 49, in <module>
    main(
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 30, in main
    project.sanity_checks(nuke=nuke)
  File "/home/twgenie/.local/lib/python3.9/site-packages/pythonanywhere/project.py", line 24, in sanity_checks
    self.webapp.sanity_checks(nuke=nuke)
  File "/home/twgenie/.local/lib/python3.9/site-packages/pythonanywhere/api/webapp.py", line 40, in sanity_checks
    raise SanityException(
pythonanywhere.exceptions.SanityException: You already have a webapp for twgenie.pythonanywhere.com.

Use the --nuke option if you want to replace it.
19:47 ~ $ pa_autoconfigure_django.py --python=3.8 https://github.com/tombiocode2/pep_genie.git --nuke

< Running API sanity checks >
   \
    ~<:>>>>>>>>>
Cloning into '/home/twgenie/twgenie.pythonanywhere.com'...
remote: Enumerating objects: 85, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 85 (delta 15), reused 80 (delta 10), pack-reused 0
Unpacking objects: 100% (85/85), 11.75 MiB | 1.66 MiB/s, done.
Updating files: 100% (99/99), done.

< Creating virtualenv with Python3.8 >
   \
    ~<:>>>>>>>>>
Removing twgenie.pythonanywhere.com...
created virtual environment CPython3.8.10.final.0-64 in 30510ms
  creator CPython3Posix(dest=/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/twgenie/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/preactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/postactivate
virtualenvwrapper.user_scripts creating /home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/get_env_details

< Pip installing django (this may take a couple of minutes) >
   \
    ~<:>>>>>>>>>
Looking in links: /usr/share/pip-wheels
Collecting django
  Using cached Django-4.2.6-py3-none-any.whl (8.0 MB)
Collecting backports.zoneinfo
  Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.0/74.0 kB 1.5 MB/s eta 0:00:00
Collecting asgiref<4,>=3.6.0
  Using cached asgiref-3.7.2-py3-none-any.whl (24 kB)
Collecting sqlparse>=0.3.1
  Using cached sqlparse-0.4.4-py3-none-any.whl (41 kB)
Collecting typing-extensions>=4
  Using cached typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Installing collected packages: typing-extensions, sqlparse, backports.zoneinfo, asgiref, django
Successfully installed asgiref-3.7.2 backports.zoneinfo-0.2.1 django-4.2.6 sqlparse-0.4.4 typing-extensions-4.8.0

< Creating web app via API >
   \
    ~<:>>>>>>>>>

< Adding static files mappings for /static/ and /media/ >
   \
    ~<:>>>>>>>>>

< Updating wsgi file at /var/www/twgenie_pythonanywhere_com_wsgi.py >
   \
    ~<:>>>>>>>>>

< Updating settings.py >
   \
    ~<:>>>>>>>>>

< Running collectstatic >
   \
    ~<:>>>>>>>>>

134 static files copied to '/home/twgenie/twgenie.pythonanywhere.com/static'.

< Running migrate database >
   \
    ~<:>>>>>>>>>
Traceback (most recent call last):
  File "/home/twgenie/twgenie.pythonanywhere.com/manage.py", line 22, in <module>
    main()
  File "/home/twgenie/twgenie.pythonanywhere.com/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 100, in handle
    self.check(databases=[database])
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/management/base.py", line 485, in check
    all_issues = checks.run_checks(
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/urls/resolvers.py", line 494, in check
    for pattern in self.url_patterns:
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
nv)
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/twgenie/twgenie.pythonanywhere.com/pep_genie/urls.py", line 24, in <module>
    path('', include('app.urls'))
  File "/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/lib/python3.8/site-packages/django/urls/conf.py", line 38, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/twgenie/twgenie.pythonanywhere.com/app/urls.py", line 2, in <module>
    from . import views
  File "/home/twgenie/twgenie.pythonanywhere.com/app/views.py", line 5, in <module>
    from .pytools import *
  File "/home/twgenie/twgenie.pythonanywhere.com/app/pytools.py", line 2, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'
Traceback (most recent call last):
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 49, in <module>
    main(
  File "/home/twgenie/.local/bin/pa_autoconfigure_django.py", line 40, in main
    project.run_migrate()
  File "/home/twgenie/.local/lib/python3.9/site-packages/pythonanywhere/django_project.py", line 132, in run_migrate
    subprocess.check_call([
  File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/twgenie/.virtualenvs/twgenie.pythonanywhere.com/bin/python', '/home/twgenie/twgenie.pythonan
ywhere.com/manage.py', 'migrate']' returned non-zero exit status 1.

Looks like you do not have requirements.txt file with opencv-python in your project repo.