How to use external python modules with microsoft azure - python

I am trying to use SymPy module in python, implemented on the Microsoft Azure platform, to no avail. This is the first of a few modules I want to use but I am finding it very difficult to find a step by step guide on how to implement any external python modules in Microsoft Azure. Has anybody had any experience with this that could offer advice? I have tried downloading the source from github and putting it in the same folder that contains my app folder. Incidentally I have set up a Flask app within azure, and cloned the app to a local folder where I seen the flask folder so thought that I could put the Sympy folder in there and call it but that hasn't worked. Help!!

Related

How to connect Azure Python package in WebJob

I have my code in my local related to our business, I am trying to deploy it to Azure but displayed with few import errors and few internal server errors.
Here I am interacting with some services like storage etc.. so I installed all the services with pip(pip is also a latest version).
I am new to Azure in interacting with SDK's. Any suggestions or steps are highly appreciated
We will have all the packages in sitepackages in our local. Whenever you install all the packages you need to install them by activating virtual environment in you local, so that they will be accessible when you import them.
You can try something like below in you code so that your webjob will load all your packages when the code runs:
import sys
package = "D:\home\site\wwwroot\env\Lib\site-packages"
sys.path.append(package)
Also you can refer to this SO where we have clear explanation similar to your problem, thanks to Gary for covering it.

Transform a python file, that uses packages like pandas, to be usable by someone that has no python environment

I have a client for whom I have created a program that utilizes a variety of data and machine learning packages. The client would like for the program to be easily run without installing any type of python environment. Is this possible?
I am assuming the best bet would be to transform the .py file into a .exe file but am unsure of how to do this if I have packages that need to be installed before the program can be run.
Are there websites that exist that allow you to easily host complex .py files on them to be run by anyone that accesses the URL?
I think you are looking for "freezing", which package everything including the interpreter, libs and packages into a single executable file.
There are several tools for this purpose:
https://wiki.python.org/moin/Freeze
https://docs.python-guide.org/shipping/freezing/
I think the use of colaboratory that is cloud service provided by Google might be better. Your client who has to sign up for Google account can not only run the python program, but also utilize any major python packages on the cloud (of course, it's possible to install the necessary packages into the client's cloud space), without constructing the python environment on client's local PC. What's more, it's at free!

Django web app deploy in Azure via Visual Studio 2017

I've made a simple app with Django in Visual Studio 2017, utilizing the default template in Visual Studio (file - new - project - python - django web application).
The app runs properly locally, but after i deploy it to Azure via Visual Studio, i can only access the page that shows:
Your App Service app has been created.
The files are all properly uploaded (i can see them in the 'site\wwwroot' folder), but the app doesn't work!
I have tried every thing that i was able to find in my searches such as: following this tutorial; adding '.azurewebsites.net' to the allowed hosts, installing azure sdk in my project virtual environment via: 'pip install azure', adding 'manage.py' to default documents, among many other things.
The thing is when i deploy (in the exact same way: right click the project, select publish, azure...) my ASP.NET apps to Azure, they work properly with minimum effort.
I am very frustated, because i really like Django framework and Azure, please help.
Thanks in advance!
In consideration of using Visual Studio to create & deploy a Django App for Azure, I suggest that you can follow the Azure offical tutorial Django and MySQL on Azure with Python Tools 2.2 for Visual Studio to inspect & make sure your steps correctly.
There are some checkpoints as below.
Make sure PTVS installed correctly, please move to here to know more details of PTVS.
Create a virtual environment for a Python version like 2.7 via PTVS.
Edit the requirements.txt file of your project, and make sure there is a record for Django like Django==1.11.2.
When you want to deploy it to Azure WebApps, please check the Python version for Azure WebApps that is the same with your project.
If your Django App doesn't still work as you want, please refer to the document to check the configuration of the web.config file via access the Kudu tool https://<your app name>.scm.azurewebsites.net and other troubleshooting content, and refer to the document to check the application settings on Azure portal.
Hope it helps. Any concern, please feel free to let me know.
After much struggle i manage to to do it!
I will explain how i did it (i've used many tutorials and forum posts answers to achieve this):
1) I've created a Django (PTVS) Web App in Azure;
2) Followed this tutorial to configure that app;
3) Make the necessary adjustments to web.config file in my project, notably the path to the python version installed via extension;
4) Published my project via Visual Studio 2017 to that Django App created in the first step.
And it worked!

How to implement WSGIProxy using setuptools in python google app engine for a webapp

Can somebody explain me how to use the setuptools inside python in google app engine to implement WSGIProxy for a webapp.
How do i utilize it, if i dont have access to the filesystem? Specifically,easy steps on how install package from python egg on GAE.
This should be relatively easy for someone who has used setuptools or installed 3rd party packages on GAE python.
I just answered almost the same question, but about a different library. The concept behind installing thirdparty libraries is exactly the same though, you need to either put a copy of the actual code in your app folder, or use a softlink to in.
GAE - Including external python modules without adding them to the repository?

How to make a module accessible for all applications including GAE deployment process

I have a Python module containing some utils that all my GAE applications may use. I created it myself. It is n a separate folder and I sometimes want to update its code, make refactorings etc. Every application I create, can take use functions from this module. Now I need to copy the module folder somewhere inside an application and import its functions. It's an ordinary procedure, nothing fancy. When I make some updates to the code of the module, I then need to overwrite this module if it is already imported in the application. Then I just deploy the application with GAE utility and all works fine. The question is - Is that possible to not have many copies of the module in every application having to overwrite them all every time I update some code inside that, but have one copy in one place and automatically import it from there? I know I can copy the module code somewhere Python searches for modules. Though, I still need to copy this module folder into the application when I deploy it into GAE environment. So, I need one copy of a module accessible for all my application when they are on my local PC and need to have that folder copied into the app when I deploy it. Is there a good and nice solution? Thanks.
You can store your module in a directory outside all your GAE apps and then create a symbolic link to that directory inside all the GAE apps directories. appcfg.py will follow the symbolic link. Quoting from the Python SDK docs:
If you make a symbolic link to a module's directory in your application directory, appcfg.py will follow the link and include the module in your app.

Categories