0

I have downloaded python-levenshtein from here and I need to use it on a cluster where I do not have sudo abilities. Is there some way to just unzip the contents and use them locally so I can use something like below in a python script?

from Levenshtein import distance

I suppose this is even a general question as well, in that I would like to know if there is a good way to use python libraries when I do not have the ability to put them in the python2.7 or python3.0 directories.

Thanks.

The Nightman
  • 5,609
  • 13
  • 41
  • 74
  • 3
    related: http://stackoverflow.com/questions/9059699/python-use-a-library-locally-instead-of-installing-it – NightShadeQueen Jul 07 '15 at 20:33
  • The link above should be able to answer the question. Personally I like to either make use of the PYTHONPATH environment variable or keep the code in the same working directory as the script being executed. – rabbit Jul 07 '15 at 20:39
  • What happens if you try to install it in a virtualenv? Do you get errors? – jpmc26 Jul 07 '15 at 20:42
  • 1
    Three options, two of which Nathan has already covered: 1) Keep code in the same directory, 2) Add the location of your library to PYTHONPATH, and 3) put a `sys.path.append("path/to/lib")` in front of your lib imports. – a p Jul 07 '15 at 20:43

1 Answers1

2

python-Levenshtein is not a pure-python implementation, but a library written in C with thin Python bindings. Thus you must install it first. To use it without sudo rights, you'd might have to create a virtual environment.