Python site-packages and import

P

Peter Saffrey

I'm trying to write a python service, with an executable in
/usr/local/bin, but modules that are kept in a sub-directory of
/usr/lib/python/site-packages.

Using apt-proxy as my template, I've put the modules in
/usr/lib/python/site-packages/mymodules and tried to import them with
import mymodules.module1. However, this doesn't seem to be working,
even though something very similar works for apt-proxy. I thought this
might be something to do with sys.path, but I can't work out why it's
different for my modules and those used by apt-proxy.

To be fair, it is past midnight, and I'm probably just being stupid.
Would anybody care to point out where? :)

Peter
 
M

Maurice LING

Peter said:
I'm trying to write a python service, with an executable in
/usr/local/bin, but modules that are kept in a sub-directory of
/usr/lib/python/site-packages.

Using apt-proxy as my template, I've put the modules in
/usr/lib/python/site-packages/mymodules and tried to import them with
import mymodules.module1. However, this doesn't seem to be working,
even though something very similar works for apt-proxy. I thought this
might be something to do with sys.path, but I can't work out why it's
different for my modules and those used by apt-proxy.

To be fair, it is past midnight, and I'm probably just being stupid.
Would anybody care to point out where? :)

Peter

your site-packages directory must be seen in python. try

import sys
sys.path

and see if your site-packages directory is listed?

maurice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top