How to pip install bcrypt on Azure webapp?
<p>Disclosure : First time Azure experience</p>

<p>I am deploying a Flask app to Azure Webapp. All deployment steps are fine till I hit the bcrypt package installation and it fails.</p>

<p>After much research based on error log output, I found out that I might need to install bcrypt using wheelhouse (*.WHL)</p>

<p>I downloaded the below files from <a href="https://pypi.python.org/pypi/bcrypt/3.1.0" rel="nofollow">here</a></p>

<ul>
<li>bcrypt-3.1.0-cp27-cp27m-win32.whl</li>
<li>bcrypt-3.1.0-cp27-cp27m-win_amd64.whl</li>
</ul>

<p>and I copied them to <code>D:\home\site\repository\wheelhouse</code></p>

<p>Then, I activated the virtualenv through KUDU and I run this command: </p>

<pre><code>d:\home\site\wwwroot\env\scripts\pip install -r requirements.txt --find-links d:\home\site\repository\wheelhouse
</code></pre>

<p>I get no messages or any log output.  When I run a <code>pip freeze &gt; tmp.txt</code> I get a blank file.</p>

<p>But when I run <code>d:\python27\scripts\pip install -r requirements.txt --find-links d:\home\site\repository\wheelhouse</code></p>

<p>It starts installing the packages until it gets to bcrypt and it errs out with this message:</p>

<blockquote>
  <p>Skipping bcrypt-3.1.0-cp27-cp27m-win32.whl because it is not compatible with
  this Python</p>
</blockquote>

<p>Which is a confusing message because the wheel is for Python 2.7</p>

<p>Since my Flask app works fine on both my Linux and Windows dev machines, I went ahead and created my own brypt wheel file in my Windows computer which runs the same Python version on Azure.  I uploaded the new <code>.whl</code>, redid the steps above and I still get the same error message</p>

<p>Extra notes:</p>

<ul>
<li>python -V on Azure console returns 2.7.8</li>
<li>python -V while virtualenv is activated also returns 2.7.8</li>
<li>Azure portal > Application Settings shows "Python version 2.7" and "Platform 32bits".</li>
<li>After deployment, all packages in requirements.txt are installed except bcrypt.</li>
<li>Visiting the web page gives a 500 error (which i expect due to missing lib)</li>
<li>I removed the virtualenv and GIT pushed the repo with <code>--find-links wheelhouse</code> at the top of requirements.txt as stated <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#_build-wheels-requires-windows" rel="nofollow">here</a>.<br>
However, I get a <code>Unable to find vcvarsall.bat</code> error. That's why I m trying to manually install via wheel</li>
<li><p>I deleted the whole virtualenv, uploaded wheel files for all required packages to \repository\wheelhouse and added <code>--no-index</code> to my pip install command. Everything gets installed except bcrypt.</p></li>
<li><p>I tried <code>bcrypt==3.1.1</code>, <code>bcrypt==3.1.0</code> and just <code>bcrypt</code> without specifying the version and it doesnt make any difference.</p></li>
</ul>

<p>I ran out of ideas.  Anyone knows what's wrong? How do I go about installing bcrypt on Azure webapp?</p>

<p>I was finally able to get the Flask app working on Azure Webapps.
Unfortunately, I couldn't do it using my usual dev tools. </p>

<p><strong>Solution</strong>:</p>

<ul>
<li>I created a VirtualEnv in Visual Studio using my <code>requirements.txt</code> file</li>
<li>Moved my Flask code to Visual Studio</li>
<li>Click on Publish to Azure Webapps</li>
</ul>

<p>It does what it does and once completed, you may still get a 500 error.
 If that is the case, use KUDU and take a look at your <code>web.config</code> file and modify the <code>WSGI_ALT_VIRTUALENV_HANDLER</code> value to match your Flask app name.</p>

<p>This is the only way I was able to get <code>bcrypt</code> to install correctly for my Flask app to work.  I hope this saves someone valuable time.</p>

<p>That's all folks.</p>

python azure pip virtualenv bcrypt