Georg Pfolz
Georg Pfolz

Reputation: 1609

Zope and buildout: Python modules

I set up a Zope installation using buildout. For one of my Zope-products I need some additional python-modules, so I figured it would be smart not to install them system-wide but in the buildout.

I need beautifulsoup4, so I that's what I tried:

[buildout]
parts = ...
        beautifulsoup4

[beautifulsoup4]
recipe = zc.recipe.egg

[zopepy]
...
eggs = ...
       beautifulsoup4

When I run a buildout, I get the message that beautifulsoup4 was installed. A peek into the zopepy shows me

sys.path[0:0] = [
    ...
    '/opt/Zope2-2.13.21/eggs/beautifulsoup4-4.3.2-py2.7.egg',
    ...

But when I start my Zope instance, I get: ImportError: No module named bs4

What's the correct way to install additional Python products in a Zope buildout?

Upvotes: 0

Views: 184

Answers (1)

sdupton
sdupton

Reputation: 1869

A few necessary corrections:

(1) You do not need to care about the zopepy part, that is just a part for an interpreter script, not for the instance itself. If you care about sys.path in both the bin/instance and bin/zopepy script (you should), make sure that you have this in [buildout] eggs= and just make sure eggs = option in instance includes ${buildout:eggs}

(2) What matters is that your [instance] part has your beautifulsoup4 egg added to its eggs option.

(3) To accomplish the above, you do not need a [beautifulsoup4] part, that is unnecessary.

(4) You really should pin a version for your distribution.

Should look like this:

[buildout]
eggs =
    beautifulsoup4
versions = versions

[instance]
recipe = plone.recipe.zope2instance
...
eggs = 
    ${buildout:eggs}

[zopepy]
...
eggs = ${instance:eggs}

[versions]
beautifulsoup4 = 4.3.2

Upvotes: 2

Related Questions