Different installations of Python on web server - NTLK installation issue

Sean Source

I am new to web development. I am having an issue importing nltk in Python when I access my shared web hosting account (Linux) with Putty.

I have a shared hosting account and I have several domains. I have started trying to develop a couple of site using Django: let's call them Site1 and Site2. I have separate virtualenvs for Site1 and Site2.

I have in the shared "base" directory an installation of Python3.6.

I then have separate installations of Python in the virtualenv bin folders for site1 and site2.

I am trying to install NLTK on Site1. I have done the following: (1) Accessed the server through Putty. (2) Run the virtualenv for Site1. (3) Typed pip install nltk. - The package is saved to the /site1-virtualenv/lib/python3.6/site-packages directory. I presume the PIP command is linked to the Python installation for Site1. (4) To download the NLTK Data, I run the Python shell by typing python in the Site1 virtualenv. When I type import nltk in the python shell, I get error:

Traceback (most recent call last): File "<stdin>", line 1,
 in <module> ModuleNotFoundError: No module named 'nltk'

I think this is because the 'python' command is running the installation of Python in the base directory of the shared hosting account; and not the installation of Python in the virtualenv for Site1.

How do I fix this issue? I realise I am probably making several bad decisions.



comments powered by Disqus