I am trying to install NLTK to a server on which I don't have shell access. I can run Python code perfectly fine, though. NLTK's installation instructions don't detail how I should go about doing this. If possible, I would like to install NLTK in a /modules folder, and keep future modules in the same folder. What should I do? Thanks!
2 Answers
Here's an idea; highly tacky, but it should work:
Use python's os.system
to execute commands through python, on the shell.
Where the instructions say sudo easy_install pip
, do this in python instead:
os.system("sudo easy_install pip")
The issue with doing this though, is that it becomes difficult to supply the sudo password. This can be fixed by running python as a sudo user (assuming you are able to do so) and them doing os.system("easy_install pip")
.
Also, this post might help with sudo
difficulties
Hope this helps

- 1
- 1

- 110,290
- 27
- 149
- 241
-
1He's running it on a server. By that, I presume he means something like a shared host. Thus `easy_install` isn't how he'll need to install it, and `sudo` won't be feasible at all. – Chris Morgan Sep 14 '12 at 04:26
-
I tried, but I think Chris is right. When I run the commands, Python just stops executing code and no new folders appear in any of my directories. I might be able to get past the sudo password issue by temporarily adjusting permissions, but after that I don't know where to go. – Gus Sep 14 '12 at 04:41
You don't need sudo access to get the NLTK running on a server, just install the packages in your own space. First I'd just try easy_install
without sudo
. But maybe there's no easy_install
, or maybe the server blocks you from launching arbitrary processes-- I would.
In that case, collect the required modules in a site-packages
folder on your home box. Once you get it working there, you can drop it to the server and adjust PYTHONPATH (or sys.path
from inside python) to find it. I've done this and it was pretty straightforward. If you can see the errors python throws when it fails to find something on the server, you can easily add any packages you forgot the first time around.

- 48,685
- 16
- 101
- 161