I'm attempting to set up a celery daemon to run on server boot with a Django REST server (should note as well that I'm doing this all within a Vagrant VM). I've followed several tutorials online (including those provided by Celery) and still cannot get this to work.
Config:
CELERYD_NODES="celery_worker"
CELERY_BIN="/usr/local/bin/celery"
CELERY_APP="proj"
CELERYD_CHDIR="/vagrant/proj/"
CELERYD_LOG_FILE="/var/log/celery/%N.log"
CELERYD_PID_FILE="/var/run/celery/%N.pid"
CELERYD_USER="celery"
CELERYD_GROUP="celery"
CELERY_CREATE_DIRS=1
proj/proj/celery.py:
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
app = Celery('proj')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
#app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
proj/proj/__init__.py:
from __future__ import absolute_import
from proj.celery import app as celery_app
In my boot log, I get this error:
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.4/dist-packages/celery/__main__.py", line 54, in <module>
main()
File "/usr/local/lib/python3.4/dist-packages/celery/__main__.py", line 30, in main
main()
File "/usr/local/lib/python3.4/dist-packages/celery/bin/celery.py", line 81, in main
cmd.execute_from_commandline(argv)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/celery.py", line 793, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 309, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 469, in setup_app_from_commandline
self.app = self.find_app(app)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 489, in find_app
return find_app(app, symbol_by_name=self.symbol_by_name)
File "/usr/local/lib/python3.4/dist-packages/celery/app/utils.py", line 235, in find_app
sym = symbol_by_name(app, imp=imp)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 492, in symbol_by_name
return symbol_by_name(name, imp=imp)
File "/usr/local/lib/python3.4/dist-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/celery/utils/imports.py", line 101, in import_from_cwd
return imp(module, package=package)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'proj'
I cannot seem to get past this error despite having everything exactly the same as the Celery docs seem to want it. Any help out there?
Related
I am getting this error while running the below command:-
Python version=3.10.8
Django version=2.1
openpyxl=2.6.2
python manage.py runserver 127.0.0.1:8000
Error:-
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x118793400>
Traceback (most recent call last):
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/opt/homebrew/Cellar/python#3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/__init__.py", line 3, in <module>
from tablib.core import (
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/core.py", line 15, in <module>
from tablib import formats
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/__init__.py", line 12, in <module>
from . import _xlsx as xlsx
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/_xlsx.py", line 14, in <module>
import openpyxl
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/__init__.py", line 6, in <module>
from openpyxl.workbook import Workbook
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/__init__.py", line 5, in <module>
from .workbook import Workbook
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/workbook.py", line 8, in <module>
from openpyxl.worksheet.worksheet import Worksheet
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/worksheet/worksheet.py", line 30, in <module>
from openpyxl.cell import Cell, MergedCell
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/__init__.py", line 4, in <module>
from .cell import Cell, WriteOnlyCell, MergedCell
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/cell.py", line 52, in <module>
from openpyxl.styles.styleable import StyleableObject
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/styleable.py", line 11, in <module>
from .builtins import styles
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/builtins.py", line 1347, in <module>
('Normal', NamedStyle.from_tree(fromstring(normal))),
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/common.py", line 113, in fromstring
parser = DefusedXMLParser(target=_TreeBuilder(),
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/ElementTree.py", line 68, in __init__
_XMLParser.__init__(self, html, target, encoding)
TypeError: XMLParser.__init__() takes 1 positional argument but 4 were given
I couldn't understand the exact issue behind this, If anyone has an idea how to resolve, please feel free share his/her suggestions.
The html argument of XMLParser() is deprecated in python3.7. You must to upgrade openpyxl to a newest version (at least 3.0.0):
https://openpyxl.readthedocs.io/en/stable/changes.html#id80
When I tried to run my python django project in my environment using the command
python -m manage startapp product
it showed me this error
Traceback (most recent call last):
File "C:\Users\ASHU\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\ASHU\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\ASHU\Desktop\Django Project API\project1_django\manage.py", line 22, in <module>
main()
File "C:\Users\ASHU\Desktop\Django Project API\project1_django\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 420, in execute
django.setup()
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\config.py", line 193, in create
import_module(entry)
File "C:\Users\ASHU\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'rest_framework'
I have already installed my Django rest framework inside my project using
pip3 install djangorestframework
Can anyone help me to reslove this error
I am trying FASTAPI with the code below and localhost is not reachable with 127.0.0.1:8000 or localhost:8000 also. Tried setting with different port numbers also.
At the end it says
NameError: name '_TypeAliasForm' is not defined
This is on windows 10 with python 3.10
from fastapi import FastAPI
app = FastAPI()
#app.get("/")
async def root():
return {"message": "Hello World"}
PS G:\pyproj\fastapiex> uvicorn main:app --reload
←[32mINFO←[0m: Will watch for changes in these directories: ['G:\\pyproj\\fastapiex']
←[32mINFO←[0m: Uvicorn running on ←[1mhttp://127.0.0.1:8000←[0m (Press CTRL+C to quit)
←[32mINFO←[0m: Started reloader process [←[36m←[1m6936←[0m] using ←[36m←[1mwatchgod←[0m
Process SpawnProcess-1:
Traceback (most recent call last):
File "c:\users\jsl\appdata\local\programs\python\python310\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\server.py", line 68, in run
return asyncio.run(self.serve(sockets=sockets))
File "c:\users\jsl\appdata\local\programs\python\python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\server.py", line 76, in serve
config.load()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\config.py", line 448, in load
self.loaded_app = import_from_string(self.app)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1049, in _gcd_import
File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
File "<frozen importlib._bootstrap>", line 1005, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 698, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 832, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File ".\main.py", line 1, in <module>
from fastapi import FastAPI
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\__init__.py", line 7, in <module>
from .applications import FastAPI as FastAPI
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\applications.py", line 3, in <module>
from fastapi import routing
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\routing.py", line 20, in <module>
from fastapi import params
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\params.py", line 4, in <module>
from pydantic.fields import FieldInfo, Undefined
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\__init__.py", line 2, in <module>
from . import dataclasses
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\dataclasses.py", line 3, in <module>
from .class_validators import gather_all_validators
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\class_validators.py", line 8, in <module>
from .errors import ConfigError
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\errors.py", line 5, in <module>
from .typing import display_as_type
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\typing.py", line 23, in <module>
from typing_extensions import Annotated, Literal
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\typing_extensions.py", line 1786, in <module>
#_TypeAliasForm
NameError: name '_TypeAliasForm' is not defined
I built a docker file that installs gdal and proj library on CentOS8.
After successfully installation of all dependencies, when i run my docker image i get OSError: libgdal.so.27: cannot open shared object file: No such file or directory.
Please how do i rectify this ?
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 6, in <module>
from .features import DatabaseFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db import models
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 50, in <module>
lgdal = CDLL(lib_path)
File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgdal.so.27: cannot open shared object file: No such file or directory
What i've tried
DISCLAIMER: I really do not understand why i did all of these and i don't know what they mean. I just want to install gdal for geodjango
RUN echo /usr/local/lib >> /etc/ld.so.conf.d/usrlocal.conf
RUN touch /etc/ld.so.conf.d/libgdal-x86_64.conf
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf
Django recommends doing this
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
i'm building a simple webservice to classify an image.
Separated my keras model classifies correctly and the flask service is running.
But when i try to use the keras model in my flask app ...
from flask import Flask
from myproject.keras_model_wrapper import get_result
APP = Flask(__name__)
#APP.route('/')
def keras_result():
return get_result()
if __name__ == 'main':
APP.run()
... an import error occurs.
* Environment: development
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Traceback (most recent call last):
File "<python_path>\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "<python_path>\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "<project_path>\.venv\Scripts\flask.exe\__main__.py", line 9, in <module>
File "<project_path>\.venv\lib\site-packages\flask\cli.py", line 966, in main
cli.main(prog_name="python -m flask" if as_module else None)
File "<project_path>\.venv\lib\site-packages\flask\cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "<project_path>\.venv\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "<project_path>\.venv\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "<project_path>\.venv\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "<project_path>\.venv\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "<project_path>\.venv\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "<project_path>\.venv\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "<project_path>\.venv\lib\site-packages\flask\cli.py", line 860, in run_command
extra_files=extra_files,
File "<project_path>\.venv\lib\site-packages\werkzeug\serving.py", line 1008, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "<project_path>\.venv\lib\site-packages\werkzeug\_reloader.py", line 337, in run_with_reloader
reloader.run()
File "<project_path>\.venv\lib\site-packages\werkzeug\_reloader.py", line 202, in run
for filename in chain(_iter_module_files(), self.extra_files):
File "<project_path>\.venv\lib\site-packages\werkzeug\_reloader.py", line 24, in _iter_module_files
filename = getattr(module, "__file__", None)
File "<project_path>\.venv\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "<project_path>\.venv\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "<python_path>\python\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tensorflow_core.keras'
I don't know if it's important that the import system searches out of my .venv
and TBH I have no idea, what exactly I should search for solving it on my own.
Every hint is welcome
I don't consider this to be a solution but Setting flask_debug=1(off) will allow you to continue working but you will need to restart the server after every change.
The issue is being tracked in TensorFlow Repo at the link below.
ModuleNotFoundError: No module named 'tensorflow_core.keras' in Flask
A Workaround that Works perfectly for Flask==1.1.1 and tensorflow==2.1.0
In Flask you should put "import tensorflow as tf" in the "__init__.py" file.
In Django you should put "import tensorflow as tf" in the "manage.py" file.