Running Pyramid app in Jython + pserve (waitress) - python

I installed Pyramid, SQLAlchemy and waitress running in virtualenv on Jython 2.7 (platform: Linux x64). Unfortunately pserve cannot start:
% pserve development.ini
Traceback (most recent call last):
File "/myapp/j1/ve/bin/pserve", line 11, in <module>
sys.exit(main())
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 60, in main
return command.run()
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 367, in run
server = self.loadserver(server_spec, name=server_name,
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 409, in loadserver
return loadserver(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 255, in loadserver
return loadobj(SERVER, uri, name=name, **kw)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 269, in loadobj
context = loadcontext(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 452, in get_context
context = self._context_from_use(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 475, in _context_from_use
context = self.get_context(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 404, in get_context
return loadcontext(object_type, name,
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 619, in get_context
entry_point, protocol, ep_name = self.find_egg_entry_point(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/myapp/j1/ve/Lib/site-packages/waitress/__init__.py", line 1, in <module>
from waitress.server import create_server
File "/myapp/j1/ve/Lib/site-packages/waitress/server.py", line 22, in <module>
from waitress.adjustments import Adjustments
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 47, in <module>
class Adjustments(object):
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 167, in Adjustments
socket_options = [
AttributeError: 'module' object has no attribute 'SOL_TCP'
Is there some workaround for this?

Related

No module named misc when implementing a simple pytest plugin?

I'm trying to implement the pytest plugin mentioned in https://github.com/pytest-dev/pytest/issues/2039, basically this plugin will print all tests that pytest finds:
## pytest_collector.py
import sys
import pytest
class DkPytestCollector(object):
def __init__(self):
self.collected = []
def pytest_collection_modifyitems(self, items):
for item in items:
self.collected.append(item.nodeid)
if __name__ == '__main__':
dkpytest_collector = DkPytestCollector()
directory = sys.argv[1]
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
print('\n\nfound:')
for nodeid in dkpytest_collector.collected:
print(nodeid)
however, when I run it I get:
(dk) go|c:\srv\lib\dk> python ..\dkbuild\dkbuild\pytest_collector.py \srv\lib\dk
Traceback (most recent call last):
File "..\dkbuild\dkbuild\pytest_collector.py", line 20, in <module>
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 50, in main
config = _prepareconfig(args, plugins)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 160, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 617, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 196, in _multicall
gen.send(outcome)
File "c:\srv\venv\dk\lib\site-packages\_pytest\helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 77, in get_result
_reraise(*ex) # noqa
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 180, in _multicall
res = hook_impl.function(*args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 943, in pytest_cmdline_parse
self.parse(args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1108, in parse
self._preparse(args, addopts=addopts)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1071, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 397, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\srv\venv\dk\lib\site-packages\_pytest\assertion\rewrite.py", line 212, in load_module
py.builtin.exec_(co, mod.__dict__)
File "c:\srv\venv\dk\lib\site-packages\py\_builtin.py", line 221, in exec_
exec2(obj, globals, locals)
File "<string>", line 7, in exec2
File "c:\srv\venv\dk\lib\site-packages\pytest_cov\plugin.py", line 6, in <module>
from coverage.misc import CoverageException
ImportError: No module named misc
if I pip uninstall pytest-cov everything works (well, except no coverage..)
How do I get this to work without uninstalling pytest-cov?

pserve development.ini --reload: fails in windows 10 64bit

I am following an article and creating my first project,
while i try the below command; the process gets into a loop and starts a server and kills it and again starts a server and kills and it keeps doing this continuously without breaking the loop and exiting.
pserve development.ini --reload
Below is the log
//---------------------------------------------------------
Starting monitor for PID 11912.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Others\Python\myBlog\lib\site-packages\hupper\ipc.py", line 322, in spawn_main
func(**kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\hupper\worker.py", line 237, in worker_main
func(*spec_args, **spec_kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 32, in main
return command.run()
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 229, in run
app = loader.get_wsgi_app(app_name, config_vars)
File "D:\Others\Python\myBlog\lib\site-packages\plaster_pastedeploy\__init__.py", line 131, in get_wsgi_app
global_conf=defaults)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 450, in get_context
global_additions=global_additions)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in _pipeline_app_context
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in <listcomp>
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 620, in get_context
object_type, name=name)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "D:\Others\Python\myBlog\lib\site-packages\weberror-0.13.1-py3.6.egg\weberror\evalexception.py", line 127
except ValueError, ve:
^
SyntaxError: invalid syntax
Killing server with PID 11912.
Starting monitor for PID 4564.
Traceback (most recent call last):
It looks like the library you're trying to use isn't built for Python 3. The except SomeException, v: syntax is only valid in Python 2. In Python 3 you must use except SomeException as v:. Try running this with Python 2 or finding a newer version of this library that supports Python 3.
Python try...except comma vs 'as' in except

Mysterious "'module' object has no attribute" error

Every time I try to serve my project I get this error:
Traceback (most recent call last):
File "/usr/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.5.2', 'console_scripts', 'pserve')()
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 313, in run
relative_to=base, global_conf=vars)
File "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 344, in loadserver
server_spec, name=name, relative_to=relative_to, **kw)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 255, in loadserver
return loadobj(SERVER, uri, name=name, **kw)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 454, in get_context
section)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 620, in get_context
object_type, name=name)
File "/usr/lib/python3.4/site-packages/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2320, in load
return self.resolve()
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2326, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/__init__.py", line 1, in <module>
from waitress.server import create_server
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/server.py", line 23, in <module>
from waitress.channel import HTTPChannel
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py", line 28, in <module>
from waitress.task import (
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/task.py", line 53, in <module>
class ThreadedTaskDispatcher(object):
File "/usr/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/task.py", line 57, in ThreadedTaskDispatcher
start_new_thread = thread.start_new_thread
AttributeError: 'module' object has no attribute 'start_new_thread'
The weird thing is, the thread module has the attribute start_new_thread
>>> from waitress.compat import (thread, Empty)
>>> thread.start_new_thread
<built-in function start_new_thread>
I started this pyramid project using python 2.7, and I am trying to switch it over to python 3.4.
Things I've tried:
updating the waitress module, it's already up to date
scratching my head

Eclipse / PyDev running a pyramid development.ini issue "pkg_resources.DistributionNotFound:"

I'm starting out with the Pyramid framework and trying to run this inside of Eclipse.
My run configuration is:
Main Module: /home/ben/env/bin/paster
Program Arguments: serve /home/ben/dev/python/pyramid/firstPyramid/first/development.ini
This virtualenv paster will serve development.ini fine from the command line. However, running this in eclipse gives:
[Invalid file specified for console output: ]
Traceback (most recent call last):
File "/home/ben/env/bin/paster", line 8, in <module>
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
invoke(command, command_name, options, args[1:])
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in invoke
exit_code = runner.run(args)
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run
result = self.command()
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/serve.py", line 276, in command
relative_to=base, global_conf=vars)
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/serve.py", line 313, in loadapp
**kw)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 203, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 223, in loadobj
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 247, in loadcontext
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 270, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 397, in get_context
global_additions=global_additions)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 492, in _pipeline_app_context
APP, pipeline[-1], global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 401, in get_context
section)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 423, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 353, in get_context
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 247, in loadcontext
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 277, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 553, in get_context
object_type, name=name)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 573, in find_egg_entry_point
pkg_resources.require(self.spec)
File "/home/ben/env/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 666, in require
File "/home/ben/env/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: MyProject
I also have PyDev using the python interpreter of the virtualenv setup.
Any ideas what may be the issue?
Here is a screenshot:
I fixed this by changing the PYHTONPATH property in pydev to also use env/bin.

"ImportError: No module named ekeet.models" When setting up Pylons with mongokit

I tried setting up a default pylons project to use mongokit as directed here:
http://namlook.github.com/mongokit/pylons.html
However it gives me the error:
>Traceback (most recent call last):
File "/usr/bin/paster", line 18, in
>command.run()
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 84, in run
>invoke(command, command_name, options, args[1:])
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 123, in invoke
>exit_code = runner.run(args)
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 218, in run
>result = self.command()
File "/usr/lib/pymodules/python2.6/paste/script/serve.py", line 276, in command
>relative_to=base, global_conf=vars)
File "/usr/lib/pymodules/python2.6/paste/script/serve.py", line 313, in loadapp
>**kw)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 204, in loadapp
>return loadobj(APP, uri, name=name, **kw)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 224, in loadobj
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 248, in loadcontext
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 278, in _loadconfig
>return loader.get_context(object_type, name, global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 409, in get_context
>section)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 431, in _context_from_use
>object_type, name=use, global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 361, in get_context
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 248, in loadcontext
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 285, in _loadegg
>return loader.get_context(object_type, name, global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 561, in get_context
>object_type, name=name)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 587, in find_egg_entry_point
>possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1954, in load
>entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/middleware.py", line 11, in
>from runnrsite.config.environment import load_environment
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/environment.py", line 8, in
>import runnrsite.lib.app_globals as app_globals
File "/home/ciferkey/Projects/runnr-site/runnrsite/lib/app_globals.py", line 2, in
>from ekeet.models import register_models
>ImportError: No module named ekeet.models
I haven't been able to find any help anywhere else or even what the module ekeet is. Why might this be happening?
Edit: I figured it out. that must have been the name of the pylons project used in the tutorial. ekeet.modules should really be what ever module you put the register_model in. I wont be so quick to ask next time!
Apparently ekeet just an example. You're supposed to make up your own name. The point is that register_models should be a list of all the modules you want to register. You need to tweak the names for your own needs.

Categories