Question

I've got a trac installation which works correctly from the command line. I deployed the trac.cgi to the proper directory, but when I open the page, I get:

Trac detected an internal error: No module named pkg_resources

Traceback (most recent call last):
  File "/some/path/htdocs/trac.cgi", line 22, in ?
    import pkg_resources
ImportError: No module named pkg_resources

pkg_resources is installed. I can import it when I run python from the command line. Permissions are right (I can read the site-packages/pkg_resources.py). The sys.path is right (includes the site-packages directory). The file starts with:

try:
  import os
  import pkg_resources

so paths are not modified before the failure.

Is there some other case where the import can fail this way?

Was it helpful?

Solution 2

I found the answer in the end. The script was run on a cluster - since I was using a virtual-python installation, some symlinks were not resolvable on other nodes. They were ok only on the machine that I was testing.

Installing setuptools in a folder created by virtual-python (i.e. in a directory that is replicated between all the servers) solved it.

OTHER TIPS

Add a file __init__.py into your directory, where you already have pkg_resources.py module. It will work for you .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top