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.
Related
I develop a project with the celery in python,and use the cython to compile the pyd files, every files is good but tasks.pyd, it fails to run. I think perhaps the bug is relate to the #decarator,and I try sererval methons with no solution, who can help me? thanks first.
here is my code in tasks.py
from celery.utils.log import get_task_logger
logger = get_task_logger(__name__)
#app.task
def myTaskFunc(arg1=None, arg2=None):
some code
Traceback (most recent call last):
File "c:\users\en-18\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\en-18\AppData\Local\Programs\Python\Python36\Scripts\celery.exe\__main__.py", line 9, in <module>
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\__main__.py", line 16, in main
_main()
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\celery.py", line 322, in main
cmd.execute_from_commandline(argv)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\celery.py", line 495, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\base.py", line 305, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\celery.py", line 487, in handle_argv
return self.execute(command, argv)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\celery.py", line 419, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\worker.py", line 223, in run_from_argv
return self(*args, **options)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\base.py", line 253, in __call__
ret = self.run(*args, **kwargs)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\bin\worker.py", line 258, in run
**kwargs)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\worker\worker.py", line 97, in __init__
self.on_before_init(**kwargs)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\apps\worker.py", line 93, in on_before_init
trace.setup_worker_optimizations(self.app, self.hostname)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\app\trace.py", line 596, in setup_worker_optimizations
app.finalize()
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\app\base.py", line 538, in finalize
_announce_app_finalized(self)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\_state.py", line 54, in _announce_app_finalized
callback(app)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\app\base.py", line 411, in cons
return app._task_from_fun(fun, **opts)
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\app\base.py", line 452, in _task_from_fun
'__header__': staticmethod(head_from_fun(fun, bound=bind)),
File "c:\users\en-18\appdata\local\programs\python\python36\lib\site-packages\celery\utils\functional.py", line 279, in head_from_fun
namespace = {'__name__': fun.__module__}
AttributeError: 'method-wrapper' object has no attribute '__module__'
comtypes > Calling CoUnititialize()
comtypes > CoUnititialize() done.
It's impossible to know without a minimal reproducible example so what follows is a guess.
I suspect #app.task requires the function to have some introspectable attribute that Cython doesn't provide by default. Things to try:
Use the directive #cython: binding=True. This makes Cython functions a custom object type that behave more like a regular function.
Use Cython 3 alpha (although who knows what version of Cython you're using here, since you don't say). It contains some improvements to function introspection (and enables binding=True by default).
Write this bit of code in Python (you could use exec for this for example).
After upgrading to Python 3.9, i'm getting these errors when running mkdocs serve I'm not a developer. I use MKDocs to build a documentation site and I wanted to upgrade the software, as a result I had to upgrade Python, pip, mkdocs and mkdocs-material..
INFO - Cleaning site directory
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 133, in serve_command
serve.serve(
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 141, in serve
config = builder()
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 136, in builder
build(config, live_server=live_server, dirty=dirty)
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 263, in build
nav = get_navigation(files, config)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 102, in get_navigation
items = _data_to_navigation(nav_config, files, config)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 157, in _data_to_navigation
return [
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 158, in <listcomp>
_data_to_navigation(item, files, config)[0]
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 150, in _data_to_navigation
return [
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 153, in <listcomp>
Section(title=key, children=_data_to_navigation(value, files, config))
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 164, in _data_to_navigation
file = files.get_file_from_path(path)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/files.py", line 31, in get_file_from_path
return self.src_paths.get(os.path.normpath(path))
File "/usr/local/Cellar/python#3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 336, in normpath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType```
Try this.
pip install -U mkdocs
I was getting same error. After updated mkdocs it resolved.
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!
I am writing a simple pyramid application, and I try to run it pserve development.ini.
I got this:
Traceback (most recent call last):
File "/apps/my/python/packages/.mytest/current/bin/pserve", line 5, in <module>
sys.exit(pyramid.scripts.pserve.main())
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 316, in run
global_conf=vars)
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 340, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 58, in fix_call
reraise(*exc_info)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/compat.py", line 23, in reraise
exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/users/is/pypi/egg_cache/at/mytest-1.9.0-py2.7.egg//mytest/__init__.py", line 108, in main
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/config/__init__.py", line 930, in scan
ignore=ignore)
File "/users/is/pypi/egg_cache/v/venusian-1.0a7-py2.7.egg/venusian/__init__.py", line 187, in scan
fn = loader.get_filename()
TypeError: zipimporter.get_filename() takes exactly 1 argument (0 given)
anyone could tell me how it comes?
Ok. I choose not to delete this question as I believe it might help other people who have the same problems.
Basically venusian does not support zipped egg. So when you produce your egg for pyramid, do not do it as zip egg.
I have a Python script that uses the nose library to set some custom options before running my tests. My project is in a virtualenv that uses Python 2.5. My global Python version was recently upgraded to 2.7, but because I'm using a virtualenv, I should be shielded. However, the last few lines look like they're referencing a non-local version of nosegae.
Where is build/bdist.linux-x86_64/egg/nosegae.py located? It looks local, but that relative path does not exist.
Traceback (most recent call last):
File "scripts/run_nosetests.py", line 70, in <module>
nose.run(argv=nose_opts)
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/core.py", line 282, in run
return TestProgram(*arg, **kw).success
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/core.py", line 117, in __init__
**extra_args)
File "/usr/lib/python2.5/unittest.py", line 767, in __init__
self.parseArgs(argv)
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/core.py", line 134, in parseArgs
self.config.configure(argv, doc=self.usage())
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/config.py", line 324, in configure
self.plugins.begin()
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/plugins/manager.py", line 93, in __call__
return self.call(*arg, **kw)
File "/home/matthew/dev/projects/jazzy_jack/lib/python2.5/site-packages/nose-0.11.3-py2.5.egg/nose/plugins/manager.py", line 161, in simple
result = meth(*arg, **kw)
File "build/bdist.linux-x86_64/egg/nosegae.py", line 129, in begin
File "build/bdist.linux-x86_64/egg/nosegae.py", line 153, in _install_hook
TypeError: __init__() takes at least 3 arguments (2 given)