2

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.

dewwwald
  • 287
  • 4
  • 14
  • 1
    Why don't you use a virtualenv? If you install a python module in the virtual env, it won't affect your Python distribution installed on the machine. – labzus Jul 04 '16 at 14:31
  • 1
    Someone jumped your gun by giving it as an answer. I should have mentioned that I have no Python experience. – dewwwald Jul 04 '16 at 14:35
  • 1
    Take a look here : [link](https://virtualenv.pypa.io/en/stable/) It's really simple, it creates a virtual environnement in wich your can install all dependencies for your script to run without affecting the machine Python. – labzus Jul 04 '16 at 14:38

1 Answers1

2

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?
Community
  • 1
  • 1
JrBenito
  • 973
  • 8
  • 30
  • Thanks. +1 however I am mending my question to include the version. Servers usually come standard with 2.7. I need the script to support that version. – dewwwald Jul 04 '16 at 14:41