ImportError: No module named 'bs4' in django only
<p>The same question has been asked a number of times but I couldn't find the solution.</p>

<p>After I install a package using pip, I am able to import it in python console or python file and it works as expected.
The same package when I try to include in django, it gives <code>import error</code>.
Do I need to modify <code>settings.py</code> file or any requirement that I need to add? I am driving django with the help of virtual env. </p>

<p>Eg:
I am using <code>BeautifulSoup</code> and I am trying to import <code>from bs4 import BeautifulSoup</code> and I am getting error <code>ImportError: No module named 'bs4'</code></p>

<p>This error only comes in django. I am not able to figure out why this is happening.</p>

<p>Screenshot attached for reference.</p>

<p><strong>1. python console - shows no error</strong></p>

<p><a href="http://i.stack.imgur.com/exmvN.png" rel="nofollow"><img src="http://i.stack.imgur.com/exmvN.png" alt="python2 and python3 console"></a></p>

<p><strong>2. django console- import error</strong></p>

<p><a href="http://i.stack.imgur.com/j0IMN.png" rel="nofollow"><img src="http://i.stack.imgur.com/j0IMN.png" alt="django console"></a></p>

<p><em>I am sorry as it is difficult to read the console but any other thing that I can include which will help me make myself more clear will be appreciated.</em> </p>

<p>You don't show either the code of your site or the command you ran (and the URL you entered, if any) to trigger this issue. There's almost certainly some difference between the Python environment on the command line and that operating in Django.</p>

<p>Are you using virtual environments? If so, dependencies should be separately added to each environment. Were you operating from a different working directory? Python usually has the current directory somewhere in <code>sys.path</code>, so if you changed directories it's possible you made <code>bs4</code> unavailable that way.</p>

<p>At the interactive Python prompt, try</p>

<pre><code>import bs4
bs4.__file__
</code></pre>

<p>That will tell you where <code>bs4</code> is being imported from, and might therefore give you a clue as to why it's not available to Django.</p>

python django