In the following hour's i tried to deploy Python with flask on Microsoft azure platform.
I used New app "flask", assign with their server. deployed by git.
after deployment finished (its showed Unable to find vcvarsall.bat)
Then I set up on options that i am using python 3.4 version and it fixed it up.
After Deployment succeeds I tried to see the site and I got :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I am a beginner in deploying and I search up all over. I really wish somebody could help me find the right answer.
Thank you very much.
Based on my research on this blog which mentioned content below about your issue:
When you see "unable to find vcvarsall.bat", it means you're
installing a package that has an extension module, but only the source
code. "vcvarsall.bat" is part of the compiler in Visual Studio that is
necessary to compile the module.
I think your issue occurred because that during the flask project deployed to azure, pip has problems installing the lxml library.As mentioned in this document, lxml library is written in C which requires a compiler before it's installation.
Unfortunately,a compiler is not available on the machine running the web app in Azure App Service. So, you need to do this compilation locally.
You can follow the steps as below:
Step 1:Use pip wheel command line to generate .whl file of lxml package.In addition,you can directly download generated .whl file here.
Step2:Create the wheelhouse folder under the requments.txt file's sibling directory and put the .whl file in wheelhouse folder.
Step3: Edit your requirements.txt to add the --find-links option at the top.
--find-links wheelhouse
lxml==3.8.0
Step4:Deploy your flask project to azure.
For more details , please refer to the Troubleshooting - Package Installation chapter in the official document and wheel document.
Hope it helps you.
Related
Generating a requirements.txt file returns this for torch:
torch==1.6.0+cpu
torchvision==0.7.0+cpu
However, with +cpu, I get an error that it is not able to find what it is supposed to install.
I navigated to this website: https://pypi.org/project/torch/#history and since I couldnt find any version saying "+cpu" so I removed the +cpu from my requirements.txt file and ran the deployment again.
Now this is where it is stuck at:
Collecting torch==1.6.0
9:41:06 PM cv-web-app: [16:41:06+0000] Downloading torch-1.6.0-cp37-cp37m-manylinux1_x86_64.whl (748.8 MB)
It is taking forever to install this and in the end I keep on getting this error:
An unknown error has occurred. Check the diagnostic log for details.
I see the diagnostic logs through the azure portal and I dont see anything logged beyond the installing of torch. As in I am unable to figure out what the error is. Maybe I am mistaking in my checking.
How do I figure out what is wrong? What does the CPU indicate?
Moreover, I am making a computer vision app. Using flask, and my system is windows. I am deploying it to azure through vscode through the "Create new web app" option.
As suggested by #ryanchill , When we deploy our Python app, Azure App Service will create a virtual environment and run pip install -r requirements.txt.
If its not happening, make sure SCM_DO_BUILD_DURING_DEPLOYMENT is set to 1.
See Configure a Linux Python app for Azure App Service for more details.
NOTE: Also as mentioned in the above MS DOC
You can install using path with putting the pytorch path in the requirements.txt
For example:
--find-links https://download.pytorch.org/whl/torch_stable.html torch==1.9.0+cpu
Reference:
. Python Webapp on Azure - PyTorch | MS Q&A .
Also please refer the below links for more information:
. MS Tutorial: Deploy Python apps to Azure App Service
.Blog PyTorch Web Service deployment using Azure Machine Learning Service and Azure Web Apps from VS Code
I have a Python Azure function which executes locally. It is deployed to Azure and I selected the 'free app plan'. The Python has dependencies on various modules, such as requests. The modules are not loaded into the app like they are locally on my machine. The function fails when triggered.
I have tried installing the dependencies using Kudu console from my site, this hangs with message cleaning up >> every time.
I have tried installing the dependencies using SSH terminal from my site, the installations succeed but i cannot see the modules when python pip list in kudo and the app still fails. I cannot navigate the directories ls does nothing.
I tried to install extensions using the portal but this option is greyed out in development-tools.
You can find a requirements.txt in your local function folder.
If you want function on azure to install the 'requests', your requirements.txt should be like this:(Azure will install the extension based on this file)
azure-functions
requests
And all these packages will be packaged into a new package on Azure, so you can not display which packages using pip list. Also, please keep in mind that Linux's Kudu feature is limited and you cannot install packages through it.
Problem seems comes from VS Code, you can use command to deploy your function app.
For example, my functionapp on Azure named 423PythonBowman2, So this is my command:
func azure functionapp publish 423PythonBowman --build remote
I quoted requests in the code, and with cmd deploy my function can works fine on portal with no errors.
Have a look of the offcial doc:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash#publish
Has anyone succesfully implemented flask-saml using Windows as dev environment, Python 3.6 and Flask 1.0.2?
I was given the link to the SAML METADATA XML file by our organisation and had it configured on my flask app.
app.config.update({
'SECRET_KEY': 'changethiskeylaterthisisoursecretkey',
'SAML_METADATA_URL': 'https://<url>/FederationMetadata.xml',
})
flask_saml.FlaskSAML(app)
According to the documentation this extension will setup the following routes:
/saml/logout/: Log out from the application. This is where users go
if they click on a “Logout” button.
/saml/sso/: Log in through SAML.
/saml/acs/: After /saml/sso/ has sent you to your IdP it sends you
back to this path. Also your IdP might provide direct login without
needing the /saml/sso/ route.
When I go to one of the routes http://localhost:5000/saml/sso/ I get the error below
saml2.sigver.SigverError saml2.sigver.SigverError: Cannot find
['xmlsec.exe', 'xmlsec1.exe']
I then went to this site https://github.com/mehcode/python-xmlsec/releases/tag/1.3.5 to get xmlsec and install it. However, I'm still getting the same issue.
Here is a screenshot of how I installed xmlsec
where does not seem to find the xmlsec.exe
documentationis asking to have xmlsec1 pre-installed. What you installed is a python binding to xmlsec1.
Get a windows build of xmlsec1 from here or build it from source
And make it available in the PATH.
xmlsec won't work properly in windows, better use Linux environment
Type the below command before giving pip install xmlsec
sudo apt-get install xmlsec1
Has anyone managed to deploy the Python ZeroMQ bindings on a vanilla AWS Elastic Beanstalk instance? Specifically I am using 64bit Amazon Linux 2016.09 v2.2.0 running Python 3.4
In my requirements.txt I have pyzmq listed - however when I deploy to AWS, the logs show that the deployment is attempting first to link against an installed libzmq (there isn't one in the standard AMI image) and then once that fails, it will try to compile libzmq from scratch which fails at a step using using cc1plus which fails (I assume) as g++ is also not part of the standard AMI image.
So my question is, how do I get either libzmq or g++ to be installed on my EC2 instance on deployment?
I read somewhere you can make a .ebextensions folder inside your deployment and inside there put a "configuration file" which I attempted to do with
packages:
yum:
g++: []
However this changes nothing. However I am guessing at what to name the configuration file in that folder e.g. test.config
Or am I going about this wrong and I need to instead fiddle with the instance installing stuff like this myself and then create a custom AMI image?
I am deploying a WebJob inside Azure Web App that uses Google Maps API and Azure SQL Storage.
I am following the typical approach where I make a WebJob directory and copy my 'site-packages' folder inside the root folder of the WebJob. Then I also add my code folder inside 'site-packages' and make a run.py file inside the root that looks like this:
import sys, os
sys.path.append(os.path.join(os.getcwd(), "site-packages"))
import aero2.AzureRoutine as aero2
aero2.run()
Now the code runs correctly in Azure. But I am seeing warnings after a few commands which slow down my code.
I have tried copying 'pyopenSSL' and 'requests' module into my site-packages folder, but the error persists.
However, the code runs perfectly on my local machine.
How can I find this 'pyopenSSL' or 'requests' that is compatible with the python running on Azure?
Or
How can I modify my code so that it pip installs the relevant packages for the python running on Azure?
Or more importantly,
How can I resolve this error?
#Saad,
If your webjob worked fine on Azure Web App, but you got inscuritywaring, I suggest you can try to disable the warning information via this configuration(https://urllib3.readthedocs.org/en/latest/security.html#disabling-warnings ).
Meanwhile,requests lib has some different with the high version, I recommend you refer to this document:
http://fossies.org/diffs/requests/2.5.3_vs_2.6.0/requests/packages/urllib3/util/ssl_.py-diff.html
And Azure web app used the Python 2.7.8 version which is lower than 2.7.9. So you can download the requests lib as version 2.5.3
According the doc referred in the warning message https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning:
Certain Python platforms (specifically, versions of Python earlier than 2.7.9) have restrictions in their ssl module that limit the configuration that urllib3 can apply. In particular, this can cause HTTPS requests that would succeed on more featureful platforms to fail, and can cause certain security features to be unavailable.
So the easiest way fix this warning, is to upgrade the python version of the Azure Web Apps. Login the Azure manager portal, change the python version to 3.4 in Application settings column:
As I test in webjob task to use requests module to request a "https://" url, and since upgrade python version to 3.4, there are no more warnings.
I followed this article and kind of 'pip installed' the pymongo library for my script. Not sure if it works for you but here are the steps:
Make sure you include the library name and version in the requirements.txt
Deploy the web app using Git. The directory should include at least
requirements.txt (only to install whatever is in requirements.txt in the virtual environment, which is shared with Web App in D:\home\site\wwwroot\env\Lib\site-packages)
add this block of code to the Python code you want to use in the WebJob zip file.
import sys
sitepackage = "D:\home\site\wwwroot\env\Lib\site-packages"
sys.path.append(sitepackage)