Forums

Getting Pyramid set up - wsgi issues

Hi all, I'm trying to get pyramid set up on python anywhere and am having trouble. If anyone can point me toward a tutorial that walks you through getting pyramid set up on Python anywhere I would be eternally grateful (I've searched bu haven't found anything complete, hoping I might have missed something).

Right now my issue is with the wsgi file. I am getting this error: cannot import name application

My code for the pyramid wsgi.py file is:

import os
import sys

path = '/path/to/env/where/my/wsgi/file/is'

if path not in sys.path:
    sys.path.append(path)

from my.wsgi import application

In my wsgi file I have the following code:

from pyramid.paster import get_app
application = get_app('/path/to/my/production.ini', 'main')

Any help would be appreciated - I have been wrestling with this for awhile!

[edited by admin -- tidied formatting for legibility]

Hi all, so I go pyramid to work, but only using python 2.7 (using the directions here: https://www.pythonanywhere.com/forums/topic/366/ and running # ../bin/python setup.py develop from the project folder at the end)

When I try to do the exact same thing but with python 3.3 I get the following error: pkg_resources.DistributionNotFound: pyramid-debugtoolbar

Any thoughts on why?

Just realized the problem is not specific to the pyramid-debugtoolbar - also get a DistributionNotFound error on waitress. I know these are both installed (in env/bin/python3.3/site-packages), they just aren't being found.

Success! Not sure why, but I had to install waitress and pyramid-debugtoolbar using pip-3.3 before I set the project up and ran the setup.py develop line. If anyone knows why would love to hear as I'm just getting started with pyramid! Thx.

Hi katimari -- right now PythonAnywhere only support Python 2.7 for web apps -- I suspect that might be the cause of most of your problems :-(

Thanks Giles!

Figured it out - newbie mistake - I was using both pip and easy_install (python setup.py develop is an easy_install related command for those like me who have no idea what they are doing :) ) Once I used only pip I didn't have to pre-install anything to get pyramid to work.

I did end up switching to python 2.7 because I was also having issues making a pyramid project using the alchemy scaffolding in python 3.3. No problems in 2.7. Don't know why, but have decided to make things easier on myself by sticking to the supported version of Python

Ah yes, it's helpful to stick to just one of pip and easy_install, to keep things simple. Personally I think pip's biggest advantage is being able to cleanly uninstall packages, and for that to work reliably you need to have installed it with pip in the first place.

From memory, if you're in a directory where you would run:

python setup.py develop

... you can instead just do:

pip install -e .

... and it should use pip to install the package in "develop mode". Note that the trailing dot refers to the current directory - instead you could pass the full path of the directory containing setup.py if you prefer.

I believe this should install any dependencies as normal with pip, but the package itself is left in its source directory and simply linked into the environment. So, any changes you make to the original source versions will be immediately reflected when you run a script which uses those libraries.