I'm trying to deploy a django web app to the Microsoft Azure and this is correctly deployed by the pipeline on DevOps Azure, but I get the error message (ModuleNotFoundError: No module named 'django) on portal Azure and cannot reach my app via the URL.
The app also works properly locally
Here is the whole error message: '''https://pastebin.com/mGHSS8kQ'''
How can I solve this error?
I understand you have tried the steps suggested in the SO thread Eyap shared, and few things here are already covers that. Kindly review these settings.
You can use this command instead - source /antenv3.6/bin/activate.
As a side note- The antenv will be available only after a deployment is initiated. Kindly check the “/” path from SSH and you should see a folder with name starting from antenv.
Browse to .python_packages/lib/python3.6/site-packages/ or .python_packages/lib/site-packages/. Kindly review the file path exists.
Review the Application logs as well (/home/LogFiles folder) from Kudu- https://<yourwebpp-name>.scm.azurewebsites.net/api/logs/docker
The App Service deployment engine automatically activates a virtual environment and runs
pip install -r requirements.txt
The requirements.txt file must be in the project root for dependencies to be installed.
For Django apps, App Service looks for a file named wsgi.py within your app code, and then runs Gunicorn using the following command:
is the name of the folder that contains wsgi.py
gunicorn --bind=0.0.0.0 --timeout 600 .wsgi
If you want more specific control over the startup command, use a custom startup command, replace with the name of folder that contains wsgi.py, and add a --chdir argument if that module is not in the project root.
For additional details, please checkout this document
Configure a Linux Python app for Azure App Service
Quickstart: Create a Python app in Azure App Service on Linux
Related
I am trying to deploy my dash app which uses dash_extensions, Dash_proxy and has multiple pages in the pages folder on GCP cloud run using gunicorn but the app cannot find the pages folder. It works perfectly fine when I use the development server but breaks in the production server because it cannot find the folder path.
The app (following code is inside the app.py file):
app = DashProxy(use_pages=True, pages_folder=pages_folder, external_stylesheets=[dbc.themes.SIMPLEX])
The app.py file and the pages folder are in the same directory
I have tried tried to following methods to get the folder path:
pages_folder="pages"
pages_folder=os.path.join(os.path.dirname(__file__), "pages")
for p in Path('.').rglob('*'):
if str(p).endswith('pages'):
pages_folder = str(p)
break
None of the above three work in when deploying on gcp using gunicorn through docker:
Dockerfile command:
CMD ["gunicorn" , "-b", "0.0.0.0:8000", "app:server"]
But if I use dev server through docker like following code it works:
CMD python app.py
Does anyone have any ideas of how to make it work with gunicorn?
Thanks for the help!
-Rexon
Yes I did. Just had to specify the root folder. This is what I did and it seems to work for me.
pages_folder=os.path.join(os.path.dirname(__name__), "pages")
app = DashProxy(__name__,use_pages=True, pages_folder=pages_folder, external_stylesheets=[dbc.themes.SIMPLEX])
server=app.server
I have a python flask API in azure app services. When deploying to it from vs code, I get a "successful deployment" message, but the app still shows the default initial web page provided as a template from Microsoft for new app services.
The current file structure looks something like this:
├───README.md
├───docs
├───data
└───src
├───main.py
└───other_files.py
I changed the file structure to look like the following:
├───README.md
├───docs
├───data
├───app.py
└───src
└───other_files.py
After deploying it like this, the application was able to start normally instead of displaying the boilerplate webpage from Microsoft. What do I need to do to have the app.py inside the src directory?
Can it actually be done?
I was able to solve it on my own by providing a custom startup command in the configuration of the app service. It can be done from the azure portal, in the "Configuration" section, or with the azure CLI.
az webapp config set --resource-group <resource-group-name> --name <app-name> --startup-file "<custom-command>"
And the custom command was:
gunicorn --bind=0.0.0.0 --timeout 600 --chdir src main:app
More details of this here: https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#customize-startup-command
I'm never done development in a career as a software programmer
I'm given this domain name on NameCheap with the server disk. Now I design Django app and trying to deploy on the server but I had problems (stated below)
[ E 2019-03-19 06:23:19.7356 598863/T2n age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/username/IOT: The application process exited prematurely.
App 644163 output: File "/home/username/IOT/passenger_wsgi.py", line 1, in <module>
App 644163 output: File "/home/username/virtualenv/IOT/3.7/lib64/python3.7/imp.py", line 171, in load_source
edited: Read more about the software supporting the WSGI is using Phusion Passenger, you could read more here; www.phusionpassenger.com
this is my passenger_wsgi.py:
from myproject.wsgi import application
I had tried several tutorials:
https://www.youtube.com/watch?v=ffqMZ5IcmSY&ab_channel=iFastNetLtd.InternetServices
https://smartlazycoding.com/django-tutorial/deploy-a-django-website-to-a2-hosting
https://hostpresto.com/community/tutorials/how-to-setup-a-python-django-website-on-hostpresto/
https://www.helloworldhost.com/knowledgebase/9/Deploy-Django-App-on-cPanel-HelloWorldHost.html
https://www.helloworldhost.com/knowledgebase/9/Deploy-Django-App-on-cPanel-HelloWorldHost.html
how to install django on cpanel
Very much applicate if you could help
When you setup a python app in cpanel, you specify the folder where you have setup the app. That will be the folder that will contain your passenger_wsgi.py file. You have to upload your django project to that same folder. To make sure they you have uploaded to the right directory, just have this simple check_ your manage.py and passenger_wsgi.py should be in the same folder. Now edit your passenger_wsgi.py and replace everything with the following code:
from myapp.wsgi import application
After this, do not forget to restart the python app. I have written a step by step guide for deploying django app on shared hosting using cpanel. Check it here.
The answer very simple, my server is using a programme name passenger, the official website for more information: https://www.phusionpassenger.com/
Now error very simply; passenger can't find my application, All I did was move my project and app folder on the same layer passenger_wsgi.py and it works like charm.
I'm working on a project which used to be run on Linux for test. It's an App Engine flex project, run with gunicorn. Gunicorn does not work on Windows if I understood well, so I've been adviced to use waitress.
I also use virtualenv in my project.
So when I'm in my virtualenv, I run waitress-serve main:app (the gunicorn cmd was gunicorn -b :8080 main:app). I get an error: It had these arguments:
1. No module named flask.
I use flask. I can see the flask folder in my virtualenv folder. And when I run python then from flask import Flask I have no error.
Is there compat issue between waitress and virtualenv ? Or I'm doing something else wrong ? (already tried to delete virtualenv folder and install all the things again)
Python modules are case sensitive
Try Flask not flask.
This is a follow on question from here.
So I managed to get the python tests to run. I have configured Jenkins using the push to deploy guide from Google
I am executing a shell command as follows:
gcloud --project=cfc-melbourne-website preview app deploy app.yaml
I get the following error
[workspace] $ /bin/sh -xe /opt/bitnami/apache-tomcat/temp/hudson678919665445088696.sh
+ gcloud --project=cfc-melbourne-website preview app deploy app.yaml
WARNING: The [application] field is specified in file [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml]. This field is not used by gcloud and should be removed.
WARNING: The [version] field is specified in file [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml]. This field is not used by gcloud and should be removed.
ERROR: The version [1] declared in [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml] does not match the current gcloud version [20150509t012658].
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Please help. Thanks.
Contents of app.yaml can be seen here
So I figured it out. Just add the version and it works !!
gcloud --project=cfc-melbourne-website preview app deploy app.yaml --version=1