This forum is no longer active. Please post your questions to our new community site

Forums Trac

TRAC_ADMIN: ImportError: No module named trac.scripts.admin - Please Help

Subscribe to  TRAC_ADMIN: ImportError: No module named trac.scripts.admin - Please Help 7 post(s), 3 voice(s)

 
Avatar chad 1 post

Hi -

I just installed Trac on my OS X machine via the Bitnami Trac installer. Everything went smooth and created the following directory structure with a project under /projects called myproject>

Top Level Directory:

Applications/trac-0.10.4-9

Sub Directories:

common
licenses
repository
subversion
apache2
projects/myproject
scripts
trac
python
sqlite

I wanted to add a user named “rick” to projects/myproject with TRAC_ADMIN privileges.

I CD into:

/Applications/trac-0.10.4-9/trac/bin

And I type:

./trac-admin permission add rick TRAC_ADMIN

And get back:

Traceback (most recent call last):
File ”./trac-admin”, line 21, in <module>
from trac.scripts.admin import run
ImportError: No module named trac.scripts.admin

Am I doing anything wrong, or is this a config issue? I’ve read that it could be a problem with my PYTHONPATH not being set up correctly, but none of the docs I’ve read tell me how to set that up.

Any help is appreciated.

 
Avatar rezaf_2000 3 post(s)

I am having the exact same problem under my Mac OS X leopard machine. Running the ./trac-admin script in the /Applications/trac-0.10.4-9/trac/bin gives me the exact same error.

Obviously the problem is with the ENvironment variables. I tried to run /Applications/trac-0.10.4-9/scripts/setenv.sh
There are three problems here:

1. It is not executable. I ran chmod +x setenv and fixed it.
2. It doesn’t include a path for PYTHONPATH. It only sets PATH, LD_LIBRARY_PATH and DYLD_LIBRARY_PATH.
3. strange as it is, it does run correctly, but the environment variables it sets do not stay in effect. In other words, if I “echo” the variables inside the file (right after it exports them) they are set correctly, but after the file is executed, if I echo the same variable (say LD_LIBRARY_PATH), it doesn’t contain anything!

Well I did copy paste those variables and exported them manually, but the trac-admin still doesn’t run.

If it helps, my default terminal on leopard is bash (found with echo $0). Oh, and the PATH that the setenv is trying to set doesn’t include all the stuff in the current PATH. In other words, one thinks it should try to only add directories to the current PATH, not remove directories from it.

In a previous install (2 months ago), I had the same problem as well. I remember I managed to set the PYTHONPATH with try and error, but there was something wrong with the md5 hashing functionality of python, and I gave up at that point.

I would appreciate if any of the developers can look into this.

 
Avatar rezaf_2000 3 post(s)

I should add that in my previous installation, I told the installer to create a project (I didn’t need SVN connection at the time), and that project worked like a charm. However, the trac-admin has always acted funny.

Thanks

 
Avatar antonio 621 post(s)

Hi,

First of all, my apologies to chad, as his first post went unnoticed and was never replied.

Secondly, I have been able to reproduce this issue, let us work on it a little bit to get it fixed.

Cheers

 
Avatar antonio 621 post(s)

Hi again,

I investigated this issue a little bit more and found that actually it works okay :)

Before using trac-admin, you need to load the environment variables as rezaf_2000 pointed out. But the way to do this is by typing from the installation directory

. scripts/setenv.sh

Once you have loaded the proper environment, the trac-admin utility should work correctly, change directory to <installdir>/trac/bin and type

./trac-admin ~/trac-0.10.4-11/projects/Project permission add antonio TRAC_ADMIN

It has worked for me. By the way, the script setenv.sh does include the PYTHONPATH variable. What version of the stack are you using?

Cheers

 
Avatar rezaf_2000 3 post(s)

Great, seems to work! Well, I can check more thoroughly tomorrow, but at least trac-admin runs and doesn’t die :-)

So, the trick was in running the setenv.sh from the installation directory and not from the scripts directory? What does the one single “dot” before scripts/setenv.sh do?

And yes, I overlooked the contents of setenv.sh. It did contain the PYTHONPATH.

Finally, I would suggest you add this information to the readme file, so that people know they should run this before trying to run trac-admin.

 
Avatar antonio 621 post(s)

The dot loads the environment from a shell script into the shell that is running the script. We will update the documentation, I am glad to hear that you finally got it working :)

Forums Trac