Edgewall Software

Ticket #7526 (closed defect: worksforme)

Opened 4 months ago

Last modified 5 weeks ago

ImportError: cannot import name compat

Reported by: Meowphetamine Owned by:
Priority: high Milestone:
Component: general Version: 0.11.1
Severity: normal Keywords: ImportError, compat.py
Cc:

Description

A new 0.11.1 installation over a new Debian 4.0 installation. Creating the env went OK and I was able to browse some pages, but threw an exception: ImportError?: cannot import name compat.

Doing a little searching, it appears that compat.py exists in two places. trac/tests/functional and trac/util.

I came across this solution on trac-users: $ find . -name compat* ./trac/tests/functional/compat.py ./trac/tests/functional/compat.pyc ./trac/util/compat.py ./trac/util/compat.pyc

$ cd trac/tests/functional $ sudo mv compat.py testcompat.py $ sudo rm compat.pyc

Attachments

Change History

Changed 4 months ago by anonymous

Bad formatting. I've learned that I should use the preview button. Here's the solution:

$ find . -name compat*
./trac/tests/functional/compat.py
./trac/tests/functional/compat.pyc
./trac/util/compat.py
./trac/util/compat.pyc

$ cd trac/tests/functional
$ sudo mv compat.py testcompat.py
$ sudo rm compat.pyc

Changed 4 months ago by Remy Blank <remy.blank@…>

  • cc remy.blank@… added

Could you please attach the full traceback from your logfile? This should give us a hint as to where the problem is located.

Changed 4 months ago by anonymous

[Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] mod_python (pid=21827, interpreter='main_interpreter', phase='PythonHandler?', handler='trac.web.modpython_frontend'): Application error [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] ServerName?: 'localhost' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] DocumentRoot?: '/htdocs' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] URI: '/' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Location: '/' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Directory: None [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Filename: '/htdocs' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] PathInfo?: '/' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Traceback (most recent call last): [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch?\n default=default_handler, arg=req, silent=hlist.silent) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/modpython_frontend.py", line 127, in handler\n from trac.web.main import dispatch_request [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 47, in ?\n from trac.web.chrome import Chrome [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 40, in ?\n from trac.util import compat, get_reporter_id, presentation, get_pkginfo, \\ [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] ImportError?: cannot import name compat [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] mod_python (pid=21828, interpreter='main_interpreter', phase='PythonHandler?', handler='trac.web.modpython_frontend'): Application error [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] ServerName?: 'localhost' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] DocumentRoot?: '/htdocs' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] URI: '/favicon.ico' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Location: '/' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Directory: None [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Filename: '/htdocs' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] PathInfo?: '/favicon.ico' [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] Traceback (most recent call last): [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch?\n default=default_handler, arg=req, silent=hlist.silent) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg) [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/modpython_frontend.py", line 127, in handler\n from trac.web.main import dispatch_request [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 47, in ?\n from trac.web.chrome import Chrome [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 40, in ?\n from trac.util import compat, get_reporter_id, presentation, get_pkginfo, \\ [Sat Aug 16 14:43:44 2008] [error] [client 127.0.0.1] ImportError?: cannot import name compat

Here is the full traceback I've had regarding this same issue. I'm not the original informer of the bug, but as far as I can see the problem is identical. For me the above solution didn't work, but the following did, taken from mailing-list:

"Well, I've resolved it by copying compat.py to compat2.py and switching all the references to it in chrome.py. Bizarre. Synchronization issue? Namespace issue? Not sure."

So now my trac.web.chrome refers to trac.util.compat2 instead of compat and everything seem to work.

Even if my site-packages are located in python version 2.4 folder, they are run by version 2.5.2.

I changed the hosts and IP's in file to local.

Hope all this information helps in finding more reliable solution for this issue.

Changed 4 months ago by anonymous

ups, formatting mistake

[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] mod_python (pid=21830, interpreter='main_interpreter', phase='PythonHandler', handler='trac.web.modpython_frontend'): Application error
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] ServerName: 'development.hanuman.dk'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] DocumentRoot: '/htdocs'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] URI: '/'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Location: '/'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Directory: None
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Filename: '/htdocs'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] PathInfo: '/'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Traceback (most recent call last):
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n    default=default_handler, arg=req, silent=hlist.silent)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target\n    result = _execute_target(config, req, object, arg)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target\n    result = object(arg)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/modpython_frontend.py", line 127, in handler\n    from trac.web.main import dispatch_request
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 47, in ?\n    from trac.web.chrome import Chrome
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 225, in ?\n    class Chrome(Component):
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 284, in Chrome\n    _default_context_data = {
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] NameError: name 'compat' is not defined
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] mod_python (pid=21831, interpreter='main_interpreter', phase='PythonHandler', handler='trac.web.modpython_frontend'): Application error
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] ServerName: 'development.hanuman.dk'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] DocumentRoot: '/htdocs'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] URI: '/favicon.ico'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Location: '/'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Directory: None
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Filename: '/htdocs'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] PathInfo: '/favicon.ico'
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] Traceback (most recent call last):
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n    default=default_handler, arg=req, silent=hlist.silent)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target\n    result = _execute_target(config, req, object, arg)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target\n    result = object(arg)
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/modpython_frontend.py", line 127, in handler\n    from trac.web.main import dispatch_request
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 47, in ?\n    from trac.web.chrome import Chrome
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 225, in ?\n    class Chrome(Component):
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33]   File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 284, in Chrome\n    _default_context_data = {
[Sat Aug 16 15:03:06 2008] [error] [client 84.250.148.33] NameError: name 'compat' is not defined

Changed 3 months ago by daybreaker12@…

I've also encountered the same error in Ubunt 7.04 + Python 2.5 + Apache2 mod_python environment after upgrading trac 0.10.4 to 0.11.1 by typing sudo python setup.py install.

But it worked well just after restarting the web server. ;)

Changed 3 months ago by erik.silkensen@…

I also encountered the same error on Mac OS X 10.5.4, Apache2.2 + mod_python. Refreshing the page once, the page would load but apparently without stylesheets, refreshing again it would appear normal. Restarting apache seems to have fixed it.

Changed 5 weeks ago by rblank

  • cc remy.blank@… removed
  • status changed from new to closed
  • resolution set to worksforme

I'll close this as worksforme, as at least some instances of this problem seem to be fixed by re-starting the web server.

Please reopen if you can provide more information, ideally a procedure to reproduce the problem.

Add/Change #7526 (ImportError: cannot import name compat)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from (none). Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.