ImportError: No module named google.appengine.api - python

when I migrate my database, i see that error.
i did init. (python manager.py db init)
and. migrate (python manager.py db migrate)
i use google app engine, flask, mac, python
what should i do?
$ python manager.py db migrate
/Library/Python/2.7/site-packages/flask_sqlalchemy/__init__.py:839: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
File "manager.py", line 3, in <module>
manager.run()
File "/Library/Python/2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/Library/Python/2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/Library/Python/2.7/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/Library/Python/2.7/site-packages/flask_migrate/__init__.py", line 182, in migrate
version_path=version_path, rev_id=rev_id)
File "/Library/Python/2.7/site-packages/alembic/command.py", line 176, in revision
script_directory.run_env()
File "/Library/Python/2.7/site-packages/alembic/script/base.py", line 421, in run_env
util.load_python_file(self.dir, 'env.py')
File "/Library/Python/2.7/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/Library/Python/2.7/site-packages/alembic/util/compat.py", line 75, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "migrations/env.py", line 87, in <module>
run_migrations_online()
File "migrations/env.py", line 70, in run_migrations_online
poolclass=pool.NullPool)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/__init__.py", line 428, in engine_from_config
return create_engine(url, **options)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/__init__.py", line 387, in create_engine
return strategy.create(*args, **kwargs)
File "/Library/Python/2.7/site-packages/sqlalchemy/engine/strategies.py", line 80, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/Library/Python/2.7/site-packages/sqlalchemy/dialects/mysql/gaerdbms.py", line 68, in dbapi
from google.appengine.api import apiproxy_stub_map
ImportError: No module named google.appengine.api

As the Error was suggesting, your runtime environment couldn't find the module. Either install it in your virtualenvironment or globally by following the instruction:
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python

Related

ModuleNotFoundError: alembic - sqlalchemy

I am trying to set up alembic to check my db, but I am getting this error when I try to run the command mentioned below.
Folder architecture:
Part of the configuration (env.py) The error is on import
from logging.config import fileConfig
from sqlalchemy import engine_from_config, pool
from src.infra.sqlalchemy.config.database import Base #The error is here
from src.infra.sqlalchemy.models.models import * #The error is here
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
Command executed in terminal (bash)
$ alembic revision --autogenerate -m "inicial"
Log error:
Traceback (most recent call last):
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\Scripts\alembic.exe\__main__.py", line 7, in <module>
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 590, in main
CommandLine(prog=prog).main(argv=argv)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 584, in main
self.run_cmd(cfg, options)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\config.py", line 561, in run_cmd
fn(
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\command.py", line 229, in revision
script_directory.run_env()
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\script\base.py", line 569, in run_env
util.load_python_file(self.dir, "env.py")
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\util\pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
File "C:\Users\bmirandl\AppData\Local\Programs\Python\Python39\lib\site-packages\alembic\util\pyfiles.py", line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "alembic\env.py", line 5, in <module>
from src.infra.sqlalchemy.models.models import *
File "C:\backEnd_py\app_blx\app_blx\.\src\infra\sqlalchemy\models\models.py", line 1, in <module>
from infra.sqlalchemy.config.database import Base
ModuleNotFoundError: No module named 'infra'

Django test parallel AppRegistryNotReady

I am trying to understand how to run django tests in parallel with in memory sqlite3.
I have django app with that structure:
gbook
order
...
tests
__init__.py
test_a1.py
test_b1.py
utils.py
test_a1.py and test_b1.py contains same code:
import time
from order import models
from .utils import BackendTestCase
class ATestCase(BackendTestCase):
def test_a(self):
time.sleep(1)
a = models.City.objects.count()
self.assertEqual(a, a)
class BTestCase(BackendTestCase):
def test_b(self):
time.sleep(1)
a = models.City.objects.count()
self.assertEqual(a, a)
utils.py is:
from django.test import TestCase, Client
from order import models
from django.conf import settings
from order.utils import to_hash
class BackendTestCase(TestCase):
fixtures = ['City.json', 'Agency.json']
def setUp(self):
self.client = Client()
self.lang_codes = (i[0] for i in settings.LANGUAGES)
...
settings_test.py:
from .settings import *
DEBUG = False
TEMPLATE_DEBUG = False
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher',] # faster
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3',
}
When I run test in single process, all goes well (about 4 sec):
python.exe manage.py test order --settings=gbook.settings_test
Then I trying to run tests in parallel:
python.exe manage.py test order --settings=gbook.settings_test --parallel=2
I get this trace (console):
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
System check identified no issues (0 silenced).
Process SpawnPoolWorker-2:
Process SpawnPoolWorker-1:
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\python\Python36-32\lib\multiprocessing\process.py", line 258, in _bootstrap
self.run()
File "C:\python\Python36-32\lib\multiprocessing\process.py", line 258, in _bootstrap
self.run()
File "C:\python\Python36-32\lib\multiprocessing\process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "C:\python\Python36-32\lib\multiprocessing\process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "C:\python\Python36-32\lib\multiprocessing\pool.py", line 108, in worker
task = get()
File "C:\python\Python36-32\lib\multiprocessing\pool.py", line 108, in worker
task = get()
File "C:\python\Python36-32\lib\multiprocessing\queues.py", line 337, in get
return _ForkingPickler.loads(res)
File "C:\python\Python36-32\lib\multiprocessing\queues.py", line 337, in get
return _ForkingPickler.loads(res)
File "C:\kvk\develop\Python\gbook\order\tests\test_a1.py", line 2, in <module>
from order import models
File "C:\kvk\develop\Python\gbook\order\tests\test_a1.py", line 2, in <module>
from order import models
File "C:\kvk\develop\Python\gbook\order\models.py", line 79, in <module>
class Agency(models.Model):
File "C:\kvk\develop\Python\gbook\order\models.py", line 79, in <module>
class Agency(models.Model):
File "C:\python\venv\gbook\lib\site-packages\django\db\models\base.py", line 110, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\base.py", line 110, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\python\venv\gbook\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config
self.check_apps_ready()
File "C:\python\venv\gbook\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config
self.check_apps_ready()
File "C:\python\venv\gbook\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
File "C:\python\venv\gbook\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
From Pycharm trace is different:
...
Traceback (most recent call last):
File "C:\python\Python36-32\lib\unittest\suite.py", line 163, in _handleClassSetUp
setUpClass()
File "C:\python\venv\gbook\lib\site-packages\django\test\testcases.py", line 1036, in setUpClass
'database': db_name,
File "C:\python\venv\gbook\lib\site-packages\django\core\management\__init__.py", line 131, in call_command
return command.execute(*args, **defaults)
File "C:\python\venv\gbook\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\python\venv\gbook\lib\site-packages\modeltranslation\management\commands\loaddata.py", line 61, in handle
return super(Command, self).handle(*fixture_labels, **options)
File "C:\python\venv\gbook\lib\site-packages\django\core\management\commands\loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "C:\python\venv\gbook\lib\site-packages\django\core\management\commands\loaddata.py", line 109, in loaddata
self.load_label(fixture_label)
File "C:\python\venv\gbook\lib\site-packages\django\core\management\commands\loaddata.py", line 175, in load_label
obj.save(using=self.using)
File "C:\python\venv\gbook\lib\site-packages\django\core\serializers\base.py", line 205, in save
models.Model.save_base(self.object, using=using, raw=True, **kwargs)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\base.py", line 838, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\base.py", line 905, in _save_table
forced_update)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\base.py", line 955, in _do_update
return filtered._update(values) > 0
File "C:\python\venv\gbook\lib\site-packages\django\db\models\query.py", line 664, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\sql\compiler.py", line 1204, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "C:\python\venv\gbook\lib\site-packages\django\db\models\sql\compiler.py", line 899, in execute_sql
raise original_exception
File "C:\python\venv\gbook\lib\site-packages\django\db\models\sql\compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "C:\python\venv\gbook\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\python\venv\gbook\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\python\venv\gbook\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\python\venv\gbook\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\python\venv\gbook\lib\site-packages\django\db\backends\sqlite3\base.py", line 328, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: Problem installing fixture 'C:\kvk\develop\Python\gbook\order\fixtures\AirportInfo.json': Could not load order.AirportInfo(pk=2411): no such table: GB_AIRPORT_INFO
It seem like migrations not works for parallel, but why?
Docs says: "--parallel" Runs tests in separate parallel processes. Each process gets its own database. And I do not need to change my code for use it.
Please, help me to understand, what am i doing wrong.
multiprocessing.cpu_count() = 4
Django version 1.11.10
Python 3.6.5
Same issue as above with MacOS and Python 3.8+. You have to explicitly set import multiprocessing; multiprocessing.set_start_method('fork') at the top of your settings.py file. But be sure to understand the side effects before you do!
I ran into a similar issue trying to use the --parallel feature on Windows.
Django's documentation states
This feature isn’t available on Windows. It doesn’t work with the Oracle database backend either.
Running the same command on Linux completed with no issues.
Parallel running is still disabled on Windows as of today. You can track the ticket that keeps progress of this feature here: https://code.djangoproject.com/ticket/31169.
And here's the code block that disables this option on Windows:
def default_test_processes():
"""Default number of test processes when using the --parallel option."""
# The current implementation of the parallel test runner requires
# multiprocessing to start subprocesses with fork().
if multiprocessing.get_start_method() != 'fork':
return 1
try:
return int(os.environ['DJANGO_TEST_PROCESSES'])
except KeyError:
return multiprocessing.cpu_count()
Source: https://github.com/django/django/blob/59b4e99dd00b9c36d56055b889f96885995e4240/django/test/runner.py#L286-L295
In reply to #Menth, this is how I enable for testing only:
# near the top of settings.py
if "test" in sys.argv[1:]:
import multiprocessing
logging.info("Using multiproc for testing.")
multiprocessing.set_start_method("fork")

Django manage.py runserver got AppRegistryNotReady: Models aren't loaded yet

I hit a problem when run django from command line with manage.py runserver.
The same code is fine with Django 1.5 several months ago.
Today I wanna pickup the code again and run upon Django 1.8.3 and python2.7.10 .
Now, got error here:
Traceback (most recent call last):
File "manage.py", line 29, 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 312, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/media/wni/study/workspace4320151111/weichun/mytheme/models.py", line 8, in <module>
from mezzanine.pages.models import Page
File "/media/wni/study/workspace4320151111/weichun/mezzanine/pages/models.py", line 34, in <module>
class Page(BasePage):
File "/media/wni/study/workspace4320151111/weichun/mezzanine/core/models.py", line 350, in __new__
return super(OrderableBase, cls).__new__(cls, name, bases, attrs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 298, in __new__
new_class.add_to_class(field.name, copy.deepcopy(field))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 226, in contribute_to_class
super(KeywordsField, self).contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 84, in contribute_to_class
cls._meta.get_fields_with_model()]:
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 56, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 432, in get_fields_with_model
return [self._map_model(f) for f in self.get_fields()]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 740, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 802, in _get_fields
all_fields = self._relation_tree
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 709, in _relation_tree
return self._populate_directed_relation_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 681, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Anyone knows how to fix it?
Thanks.
Wesley
I think you need to change your wsgi.py file as you go for different version of Django.
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'YourAppName.settings'
application = WSGIHandler()
And try to comment all third party application imported in settings.py.
1] ./manage.py runserver will use your wsgi.py however it looks like the stack trace you've shown at the top does not include the wsgi file. Therefore the error is occurring before the wsgi file is loaded.
2] This could well be an issue with your Django settings. For example,may in LOGGING a filename in a non-existent directory.
3] or check this

CKAN error after enabling harvester module - 'module' object has no attribute 'ITranslation'

After enabling the harvester module for CKAN, I'm getting the following error in ckan_default.error.log (and the web application returns status 500 until I disable the harvest and ckan_harvester plugins from config file):
mod_wsgi (pid=1605): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=1605): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
Traceback (most recent call last):
File "/etc/ckan/default/apache.wsgi", line 9, in <module>
application = loadapp('config:%s' % config_filepath)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/util.py", line 56, in fix_call
val = callable(*args, **kw)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 58, in make_app
load_environment(conf, app_conf)
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 232, in load_environment
p.load_all(config)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 134, in load_all
load(*plugins)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 148, in load
service = _get_service(plugin)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 254, in _get_service
return plugin.load()(name=plugin_name)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/ckan/default/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/plugin.py", line 31, in <module>
class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation):
File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/plugin.py", line 43, in Harvest
p.implements(p.ITranslation, inherit=True)
AttributeError: 'module' object has no attribute 'ITranslation'
I found some similar errors but not for CKAN and 'ITranslation', any help appreciated.
Thanks
Fixed it! Just upgraded current 2.5.0a installation to latest DEV version (2.6.0a) and it worked without problems...
Thanks!

Gevent - ImportError: No module named mako_templating

I’m following a video from 2012 - Gevent-socketio, cross-framework real-time web live demo (https://www.youtube.com/watch?v=zhh_N5pmHBY)
I’m working on Ubuntu 15.04.
At 8 mins, in init.py he corrects config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory') but after that I still can’t get it to work. The error I’m getting is below.
Any and all help would be greatly appreciated.
Thank you
(env)cloud#cloudnetwork:~/Code/python/3/moo/Moo$ pserve --reload development.ini
Starting subprocess with file monitor
Traceback (most recent call last):
File "/home/cloud/Code/python/3/moo/env/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.5.7', 'console_scripts', 'pserve')()
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 58, in main
return command.run()
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 328, in run
global_conf=vars)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 363, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/home/cloud/Code/python/3/moo/Moo/moo/__init__.py", line 10, in main
config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/util.py", line 528, in wrapper
result = wrapped(self, *arg, **kw)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/config/rendering.py", line 33, in add_renderer
factory = self.maybe_dotted(factory)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 825, in maybe_dotted
return self.name_resolver.maybe_resolve(dotted)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 320, in maybe_resolve
return self._resolve(dotted, package)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 327, in _resolve
return self._zope_dottedname_style(dotted, package)
File "/home/cloud/Code/python/3/moo/env/local/lib/python2.7/site-packages/pyramid/path.py", line 382, in _zope_dottedname_style
__import__(used)
ImportError: No module named mako_templating
The easiest way to register a new extension to be processed as a Mako template in Pyramid is as follows:
config.include('pyramid_mako')
config.add_mako_renderer('.html')
This will set up the renderer correctly.
Mako templating was removed from the Pyramid core framework, and thus pyramid.mako_templating.* no longer exists.
Depending on how you installed pyramid, you also need to install pyramid_mako, for instance by running pip install pyramid_mako. It's a separate module and is not a part of pyramid itself.

Categories