[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

site package does not work

Erik Martinson via Python-list wrote:

> I am trying to dynamically add a site-package to a script that is run as a
> cron job. The method adduseristepackages does not seem to do anything.

The function addusersitepackages() seems to be un(der)documented; looking at 
the source it turns out that the expected argument is a sequence of known 
paths rather than a directory you want to add.

If you need to add a directory that is not deteced by getusersitepackages() 
you can do so with addsitedir(my_directory) or by modifying sys.path 
directly with sys.path.append(my_directory).


> site.addusersitepackages('/home/erik/.local/lib/python3.6/site-packages'))

I recommend that you install the required packages as root rather than trick 
root into executing user-modifiable code, or, even better, that you run the 
cron job as user "erik".