我有一个Pyramid项目,我正在尝试从VBox迁移到Docker。当我尝试使用pserve development.ini
我得到了这个回溯:
> /app/venv/bin/pserve /app/testsite_config/development.ini --reload
---> Running in 72665248bbeb
Starting monitor for PID 12.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/app/venv/local/lib/python2.7/site-packages/hupper/ipc.py", line 315, in spawn_main
func(**kwargs)
File "/app/venv/local/lib/python2.7/site-packages/hupper/worker.py", line 267, in worker_main
func(*spec_args, **spec_kwargs)
File "/app/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 32, in main
return command.run()
File "/app/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 253, in run
app = loader.get_wsgi_app(app_name, config_vars)
File "/app/venv/local/lib/python2.7/site-packages/plaster_pastedeploy/__init__.py", line 131, in get_wsgi_app
global_conf=defaults)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 253, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 277, in loadobj
global_conf=global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 302, in loadcontext
global_conf=global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 326, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 455, in get_context
global_additions=global_additions)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 564, in _pipeline_app_context
APP, pipeline[-1], global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 459, in get_context
section)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 481, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 412, in get_context
global_conf=global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 302, in loadcontext
global_conf=global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 334, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 625, in get_context
object_type, name=name)
File "/app/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 651, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/app/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2324, in load
return self.resolve()
File "/app/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2330, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named testsite
Server with PID 12 exited with code 1.
Waiting for changes before reloading.
这是我的 development.ini 文件:
[app:testsite]
use = egg:testsite
reload_templates = true
debug_authorization = false
debug_notfound = false
debug_routematch = false
debug_templates = true
default_locale_name = en
pyramid.includes = pyramid_debugtoolbar
pyramid_tm
pyramid_mailer
jinja2.directories = testsite:templates
#SQlalchemy configuration (The prefix `sqlalchemy.` can be changed IF you change it in __init__.py's engine_from_config() call too
# database
sqlalchemy.url = sqlite:///%(here)s/testsite.db
#sqlalchemy.pool_recycle = 3600
#sqlalchemy.pool_size = 20
# email testsite list
email_list = %(here)s/email_list.txt
[pipeline:main]
pipeline =
testsite
[server:main]
use = egg:Pyramid#wsgiref
host = 0.0.0.0
port = 6543
# Begin logging configuration
[loggers]
keys = root, testsite
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[logger_testsite]
level = DEBUG
handlers =
qualname = testsite
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
# End logging configuration
这是我的 setup.py :
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
#README = open(os.path.join(here, 'README.txt')).read()
#CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires=['pyramid>=1.4',
'pyramid_jinja2',
'jinja2',
'jinja2_alchemy_starter',
'sqlalchemy',
'waitress',
'pyramid_tm',
'pyramid_debugtoolbar',
'pyramid_mailer',
'zope.sqlalchemy']
setup(name='testsite',
version='0.0',
description='testsite',
# long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web pyramid pylons',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=requires,
test_suite="testsite",
entry_points = """\
[paste.app_factory]
main = testsite:main
""",
paster_plugins=['pyramid'],
)
要完全复制所有内容,这是我使用此行构建的Docker容器(https://github.com/rajsinghUSA/testsite):
docker build -t image_from_dockerfile -f testsite.Dockerfile。