ValueError: Could not find a default download directory of nltk
<p>I have problem on import nltk.
I configured apache and run some sample python code, it worked well on the browser.
The URL is : /localhost/cgi-bin/test.py.
When I import the nltk in test.py its not running. The execution not continue after the "import nltk" line.And it gives me that error ValueError: Could not find a default download directory 
But when I run in the command prompt its working perfect.
how to remove this error?</p>

<p>The environment in which your CGI script is executed is not the same as when you run it in from a terminal or similar. Specifically, environment variables like <code>$PYTHONPATH</code> might not be set to what you need.</p>

<p>An ugly but safe work-around is adding the needed directories inside the script, before any third-party import statements:</p>

<pre><code>import sys
sys.path.append('path/to/package-parent')  # change this to what you actually need
import nltk
</code></pre>

<p>To find the location of NLTK or whatever causes trouble, import it in an interactive session.
Then, typing the module/package name will print the location:</p>

<pre><code>&gt;&gt;&gt; import nltk
&gt;&gt;&gt; nltk
&lt;module 'nltk' from '/usr/local/lib/python3.4/dist-packages/nltk/__init__.py'&gt;
</code></pre>

<p>So, you would append '/usr/local/lib/python3.4/dist-packages' to <code>sys.path</code> in this case.</p>

<p>I'm not entirely sure if this also applies to the "default download directory", but you can give it a try.</p>

python nltk