Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install new packages for pyramid without getting a pkg_resources.DistributionNotFound: once a project has been created

I have installed pyramid and successfully created a project, but when I try to add new packages to the setup.py requirements they always give me a pkg_resources.DistributionNotFound error.

The packages are installed, and this only happens if I try to install new packages after I run ../bin/python3.3 setup.py develop It doesn't matter what packages it is.

The only way I have solved (not really), is setting up a new virtual environment and installing the packages before I create the project and run setup.py develop.

Obviously I'm doing something wrong. Is there anything I need to do beside pip install the package? Is this some kind of pathing issue? I'm new to this so your help would be so very appreciated!

*Adding my installation process in case anyone happens to see something wrong with it. Also including my wsgi file.

Created a virtualenv easy_install-3.3 env

Activated the virtualenv source env/bin/activate

Installed pyramid cd env ./bin/easy_install-3.3 pyramid

Created a project ./bin/pcreate -s starter myprojectname

Ran setup.py cd myprojectname ../bin/python3.3 setup.py develop

At this point I get the following error: pkg_resources.DistributionNotFound: waitress

Installed Waitress ../bin/easy_install-3.3 waitress

Ran setup.py again (not sure if I should be doing this) ../bin/python3.3 setup.py develop

Still see the error

My .wsgi file contains the following (not sure if this is important to this question or not): activate_this = "/home/account/env/bin/activate_this.py" execfile(activate_this,dict(__file__=activate_this))

import os import sys

path = '/home/account/env/lib/python3.3/site-packages'

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

from pyramid.paster import get_app application = get_app('/home/account/env/myprojectname/production.ini', 'main')

like image 850
Kate B. Avatar asked Jun 20 '13 17:06

Kate B.


2 Answers

Using Michael's suggestions above, I was able to solve his issue. I didn't even need to install any packages manually. Once everything was working, if I added a requirement to my setup.py file (which is created when you make a pyramid project) and ran pip install -e . again everything was installed perfectly. The problem was caused by how I was installing things. Here is my final process in case it helps any other newbies to pyramid:

  1. Created a virtual environment virtualenv-3.3 env

  2. Activated the env source env/bin/activate

  3. Moved to environment directory cd env

  4. Installed pyramid pip install pyramid

  5. Created a project ./bin/pcreate -s starter myprojectname

  6. Moved to my project directory cd megaproject

  7. Ran install pip install -e .

  8. updated my wsgi file with my env and project settings

  9. reload the app and jumped for joy to see the lovely pyramid starter page

like image 169
Kate B. Avatar answered Nov 14 '22 23:11

Kate B.


pip and setup.py develop should not to be mixed. The latter uses easy_install which is not compatible with pip in the case of namespace packages (these are packages that are installed as subpackages of another parent, such as zope.sqlalchemy installing only the .sqlalchemy part of the full zope.* package). Namespace packages will cause problems between pip and easy_install. On the other hand, most other packages will work fine with whatever system you choose but it's better for you to be consistent.

Another thing to double check is that you are actually installing the packages into your virtualenv. You should be able to open the python cli in your virtualenv and import the package. If you can't, then it's probably not installed.

like image 45
Michael Merickel Avatar answered Nov 14 '22 22:11

Michael Merickel