Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import Python plugins from a folder

I want to put a python script with module script PIL on a server. The server might not have PIL installed. (This is why I want to load the file myself)

If possible, how can I have the python script import Image Library from the current directory of the script without having it installed on the machine?


Using python virtual machine I am using v2.7 of python locally, as on server.

like image 946
dewwwald Avatar asked May 29 '26 03:05

dewwwald


1 Answers

One option is to import modules from a relative path as described here.

It is also possible to use virtual environments where you pack everything you need and don´t mess with python installations on the server. Look it here and here

Other references:

  1. Loading all modules in a folder in Python
  2. How to do relative imports in Python?
like image 63
JrBenito Avatar answered May 31 '26 11:05

JrBenito



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!