Iv'e been doing some maintenance on the server side and then deployed the app to the GAE. since I deployed the new version, it doesn't recognize the flask_sqlalchemy module. It worked perfectly before the commit. is there something that I'm missing?
Ok for anyone getting this error, apparently I forgot to copy the libraries to the lib folder. I did that by using the command: pip install -t lib -r requirements.txt
Related
After I tried to deploy my Django website on Azure, I got an error saying:
ModuleNotFoundError: No module named 'django'
I added a requirements.txt in the root directory of my Django project, am I missing anything else? I've tried to install Django from Kudu BASH but it gets stuck on "Cleaning Up".
Here is the full error: https://pastebin.com/z5xxqM08
I built the site using Django-2.2 and Python 3.6.8.
Just summarized as an answer for other people. According to your error information, I can see that you tried to deploy your Django app to Azure WebApp on Linux based on Docker. So there are two offical documents will help as below.
Quickstart: Create a Python app in Azure App Service on Linux
Configure a Linux Python app for Azure App Service
The error ModuleNotFoundError: No module named 'django' indicated that there is not django package installed on the container of Azure Linux WebApp.
Due to the content of Container characteristics of #2 document above as below,
To install additional packages, such as Django, create a requirements.txt file in the root of your project using pip freeze > requirements.txt. Then, publish your project to App Service using Git deployment, which automatically runs pip install -r requirements.txt in the container to install your app's dependencies.
So the possible reason is the requirements.txt file not in the corrent path of your project or container after deployed, which path should be /home/site/wwwroot/requirements.txt on the container or the root of your project like the offical sample Azure-Samples/djangoapp on GitHub.
I had the same problem. requirements.txt was in my repository, but randomly I started getting the same error ModuleNotFoundError: No module named 'django' after changing a setting or restarting the service or something. Nothing I could do, change the setting, or reboot repeatedly fixed it. Finally what worked for me was this:
Make a small change to the code and commit it, and push it up to the app service.
This fixed it for me. It has happened a couple times now and every time this solution has worked for me. It seems like the App Service sometimes gets in this state and needs to be jostled with this trick?
I recently got a server through DigitalOcean and I'm playing around with a Flask App.
The app works perfectly fine on my computer when I run it locally. But it doesn't work when hosted on DigitalOcean. Both Virtual Environments are the same.
When I do 'pip freeze', the output is:
coverage==4.0.3
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.7
Flask-Login==0.3.2
Flask-SQLAlchemy==2.1
Flask-WTF==0.12
gunicorn==19.4.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
SQLAlchemy==1.0.11
visitor==0.1.2
Werkzeug==0.11.3
wheel==0.24.0
WTForms==2.1
But I get an error when I look in Apache error log:
ImportError: No module named flask.ext.bootstrap
I'm not sure why it can't find it. Like I said, it works fine on my computer when I run it locally.
I also tried 'from flask_bootstrap import Bootstrap' instead of 'from flask.ext.bootstrap import Bootstrap'. Both works locally, but neither work on DigitalOcean server.
Any suggestions?
Please check how you configured Apache. It's probably using the system default Python without your virtual env.
When making Flask Apps using digitalocean, this tutorial is a lot more up to date and simpler than the one I posted above:
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04
I did the process again, but this time using gunicorn and nginx and found the overall process a lot easier.
I am new to Google App Engine and just deployed a sample project "flask" to my GAE. But it shows
"Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds."
I have read a lot of similar questions on stackoverflow, but I don't find any who has this problem even for the sample project provided by GAE itself.
I just ran into this issue and found the answer in the sample project README file. The problem was that flask isn't included in the sample project, so I was getting an flask import error. You just have to cd to your project directory (appengine-flask-skeleton-master) and run the following...
pip install -r requirements.txt -t lib
If you are on linux you will probably need to include sudo before the command.
You should now see flask in the lib folder in the sample project directory. If you update your project again, the import error should be resolved.
You can test your app locally by running:
dev_appserver.py .
Hope that helps.
My Python app needs web.py to run but I'm unable to figure out how to get it up to bluemix. I see no options using cf push. I tried to "import web" and added some additional code to my app without success.
When I push my Python app to bluemix without web.py it fails (naturally) since it does not have what it needs to run.
I'm sure I'm just missing an import mechanism. Any help?
I recommend that you try out this starter template on GitHub. It is enabled with a deploy to Bluemix button that automatically creates a python runtime and postgress database with Django installed. https://github.com/fe01134/djangobluemix
The project includes the requirements.txt file to ensure you have the right dependencies and also the .settings file to read the database user id and password from VCAP Services. It also leverages Declared services in the manifest file to create a database service for you.
Here is a YouTube Tutorial on how to deploy Python app on Bluemix https://www.youtube.com/watch?v=qIcHQQNUmlE&list=PLvsG7O_a5F2dAjsNp6aRACP6vkqdgsZ33&index=5
The cause for this problem was that I was not correctly telling my Python app the needed configuration information when I pushed it out to Bluemix.
What I ended up having to do was add a requirements.txt file and a Procfile file into the root directory of my Python application, to draw that connection between my Python app and the needed libraries/packages.
In the requirements.txt file I specified the library packages needed by my Python app. These are the file contents:
web.py==0.37
wsgiref==0.1.2
where web.py==0.37 is the version of the web.py library that will be downloaded, and wsgiref==0.1.2 is the version of the web server gateway interface that is needed by the version of web.py I am using.
My Procfile contains the following information:
web: python .py $PORT
where myappname is the name of my Python app, and $PORT is the port number that my Python app uses to receive requests.
I found out too that $PORT is optional because when I did not specify $PORT my app ran with the port number under the VCAP_APP_PORT environment variable for my app.
From there it was just a matter of pushing my app out to Bluemix again only this time it ran fine.
just use pip freeze
pip freeze > requirements.txt
add the requirements.txt to your project
when deployed it will automaticly install the dependency
I've built a web app using django deployed on openshift. I'm trying to add the third party reusable app markdown-deux. I've followed the install instructions (used pip) and it works fine on the localhost development server.
I've added 'markdown_deux' to my settings.py and tried it with and without a requirements.txt. However, I still get a 500 error and from rhc tail the error "Import error: no module named markdown_deux".
I've tried restarting my app and resyncing the db but I'm still getting the same errors. I've RTFM but to no avail.
Openshift has mechanisms to automatically check and add dependencies after each git push, depending on your application type. So you don't need to install dependencies manually.
For python applications modify the projects setup.py.
Python application owners should modify setup.py in the root of the git repository with the list of dependencies that will be installed using easy_install. The setup.py should look something like this:
from setuptools import setup
setup(name='YourAppName',
version='1.0',
description='OpenShift App',
author='Your Name',
author_email='example#example.com',
url='http://www.python.org/sigs/distutils-sig/',
install_requires=['Django>=1.3', 'CloudMade'],
)
Read all details at the Openshift Help Center.
You've used pip to install it locally, but you actually need to install it on your server as well. Usually you would do that by adding it to the requirements.txt file and ensuring that your deployment process includes running pip install -r requirements.txt on the server.