You are not logged in.
Pages: 1
hi all,
just working on my new release for batterymon however now i've split the source into several files when i try to run it comes up saying that it can't find the modules.
they are stored under /usr/share/batterymon/ when you install via the PKGBUILD that i'm working on.
does anyone know how i can fix this so that i can do the following
1. run from any location on the command line.
2. run from the working dir of the project without having /usr/share/batterymon in place?
Regards
Matthew
"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson
Offline
hi all,
just working on my new release for batterymon however now i've split the source into several files when i try to run it comes up saying that it can't find the modules.
they are stored under /usr/share/batterymon/ when you install via the PKGBUILD that i'm working on.does anyone know how i can fix this so that i can do the following
1. run from any location on the command line.
2. run from the working dir of the project without having /usr/share/batterymon in place?Regards
Matthew
For 1: you can place the actual script in /usr/bin, or create a symlink to the script in /usr/bin (after making the actual script executable).
Example:
sudo chmod +x /home/lswest/batterymon
sudo ln -s /home/lswest/batterymon /usr/bin/batterymon
For 2. I'm not sure what exactly what you mean...maybe create symlinks for those modules?
Lswest <- the first letter of my username is a lowercase "L".
"...the Linux philosophy is "laugh in the face of danger". Oops. Wrong one. "Do it yourself". That's it." - Linus Torvalds
Offline
the main script batterymon.py is stored in /usr/bin if i link the other scripts in there do i still need to make them executable?
it does seem a little messy to link all the py files into /usr/bin
from what i can work out python is trying to load the module but because it's not in the python modules path it can't find it. and beacuse the batterymon program can be launched from anywhere the working dir is set to the location that you run it from . eg ~/
"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson
Offline
You could also place the modules in the python path, but I'd suggest putting it in a folder outside of /usr/bin and seeing if you can specify a path when importing something in Python (I'm not sure you can).
To answer you question, I think they will need to be executable if you expect to run them, but if they will just be imported chances are they don't need to be (you can always just test this out though).
Hope that helps,
Lswest
Lswest <- the first letter of my username is a lowercase "L".
"...the Linux philosophy is "laugh in the face of danger". Oops. Wrong one. "Do it yourself". That's it." - Linus Torvalds
Offline
this is exactly my problem but i'm not 100% sure on using the fix that has been sugested. has anyone come across this before?
"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson
Offline
That should work fine, it's like putting the program in a folder and running a bash script with "python /path/to/batterymon "$@"" where "$@" are all the command-line arguments being passed to the script. So you could move the batterymon.py to the same folder as the modules, and create a new script in /usr/bin with python /usr/share/batterymon/batterymon.py "$@" which will effectively run the program like batterymon.py <arguments>.
Lswest <- the first letter of my username is a lowercase "L".
"...the Linux philosophy is "laugh in the face of danger". Oops. Wrong one. "Do it yourself". That's it." - Linus Torvalds
Offline
Install your modules to "/usr/lib/python2.6/site-packages/batterymon/". That seems to be how other packages do it.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I would recommend using distutils and a setup.py file:
Offline
I would recommend using distutils and a setup.py file:
Forget my previous suggestion. This one is much better.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
iirc you could also use sys.path.append()
☃ Snowman ☃
Offline
Pages: 1