I'm working on migrating a Python 2.7/1st Gen/GAE app to Python 3/2nd Gen/GAE.
My current step is replacing google.appengine.ext.deferred with the Python Client for Cloud Tasks API.
Here is where I'm at:
Still using Python 2.7
Latest updates with gcloud components update
Following the Python Client docs, I added google-cloud-tasks==1.5.0 to my requirements.txt
google-cloud-tasks needs grpcio so I added - name: grpcio\n version: latest to app.yaml
Now dev_appserver.py is giving me the error ImportError: No module named enum
I'm not finding much documentation online so I'm wondering... Is it possible to use google-cloud-tasks with Python 2.7 on app engine?
If so, how do I fix the last error above?
Related
I am following the “Getting Started With Django on Render” tutorial (https://render.com/docs/deploy-django#update-your-app-for-render) and all was going well until I got to “Configure Django for PostgreSQL”. I have everything copied correctly but I am getting errors now when I run python manage.py runserver this is the error:
File "/Users/user/Desktop/First_Program/Portfolio_Projects/Charter_Django_App/Charter_Django_App/config/settings.py", line 14, in <module>
import dj_database_url
ModuleNotFoundError: No module named 'dj_database_url'
even though when I run poetry show it clearly says it is installed
asgiref 3.5.2 ASGI specs, helper code, and adapters
brotli 1.0.9 Python bindings for the Brotli compression library
dj-database-url 1.0.0 Use Database URLs in your Django Application.
dj-email-url 1.0.6 Use an URL to configure email backend settings in your Django Application.
django 3.2.16 A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
django-cache-url 3.4.2 Use Cache URLs in your Django application.
environs 9.5.0 simplified environment variable parsing
gunicorn 20.1.0 WSGI HTTP Server for UNIX
marshmallow 3.19.0 A lightweight library for converting complex datatypes to and from native Python datatypes.
packaging 22.0 Core utilities for Python packages
psycopg2-binary 2.9.5 psycopg2 - Python-PostgreSQL Database Adapter
python-dotenv 0.21.0 Read key-value pairs from a .env file and set them as environment variables
pytz 2022.6 World timezone definitions, modern and historical
setuptools 65.6.3 Easily download, build, install, upgrade, and uninstall Python packages
sqlparse 0.4.3 A non-validating SQL parser.
whitenoise 6.2.0 Radically simplified static file serving for WSGI applications
And also shows in poetry.lock file.
If anybody knows why this is happening and can please give me some insight. I followed the tutorial to the T but am new to using poetry.
I am also a bit confused as to where I store the environment variables such as SECRET_KEY as the tutorial is not very descriptive at that point. I am used to using pip install environs[django] then running
env = Env() env.read_env()
And reading from the .env file
Thank you x1000 in advance to anybody that may help me get my application running
I'm guessing the error is from you're virtualenv either you're not activating it or the packages are not installed in the virtualenv.
if you are using vscode try Ctrl + Shift + p and search for Python: select interpreter make sure the interpreter vscode is using is you're venv if click on it and go to myvenv/Scripts/ there you can see a file python.exe choose it.
It's hard to be sure as you didn't post that many things to begin with. But if you managed your virtual environment through poetry, then you should run :
poetry run python manage.py runserver
(instead of python manage.py runserver)
(As for environment variables, I've been advised to try python-dotenv. I haven't had the chance to test it yet, but it seems easier than most things. I'm not sure if that will help you with render.yaml though...)
I have a shared Cpanel host with the Litespeed web server. I want to deploy a Django application on it. After creating a Python application inside the Cpanel where I have not deployed the application on the host I try loading the website, and instead of displaying the Django version, I face 503 Unavailable!!
Also inside the "stderr.log" file, there is the following error.
/usr/local/lsws/fcgi-bin/lswsgi_wrapper: line 9: /opt/alt/python39/bin/lswsgi: No such file or directory
I'm creating the application with Python 3.9.
But it works when I create it with Python 3.8 and show the following message when I load the web,
It works!
Python 3.8.6
The issue is mostly caused by the lack of the Python 3.9 WSGI package. On out-of-date versions of LiteSpeed, the package needs to be installed manually.
To work around this, first ensure that LiteSpeed is up to date. LiteSpeed must be at version 5.4.10 for this to work. Once that is confirmed, execute the following script from LiteSpeed. It will pull the required Python Selector packages:
/usr/local/lsws/admin/misc/enable_ruby_python_selector.sh
Refer cpanel support
Hey i have an django application which is working fine locally but its not working when it is hosted on a web showing below error
django.core.exceptions.ImproperlyConfigured: Error loading pyodbc module: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/site/wwwroot/antenv/lib/python3.7/site-packages/pyodbc.cpython-37m-x86_64-linux-gnu.so)
Did i miss anything at the time of hosting?
Assuming you got this issue during deployment via DevOps pipeline, you could specify an exact version of python in the UsePythonVersion (including minor version) task.
Supported python versions, you could check the software of the agent image:
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
Also, you could try the solution in the following case, by adding deadsnakes repo, installing 3.7 and symlink python to python3.7:
https://github.com/actions/virtual-environments/issues/2634#issuecomment-775808754
I am writing after a lot of searching and trial and error with no luck.
I am trying to deploy a service in app engine.
You might be aware that deploying on app engine is usually practiced a two step process
1. Deploy on local dev app server
2. If step 1 succeeds deploy on cloud
My problems are with step 1 when I include third party python libraries such as numpy, sklearn, gcloud etc.
I am trying to deploy a service in local devapp server. When I import numpy or any other third party libraries in my main.py script it throws an error saying unable to find the module.
I am using cloud sdk and have two python distributions, the default python 2.7 and anaconda with python 2.7. When I change the path to look for the modules in anaconda distribution, it fails to find module ‘setup’ required by the cloud sdk.
Is there a way to install the cloud sdk for anaconda distribution ?
Any help/pointers will be much appreciated!
When using app engine python standard environment, you can install pure python 3rd party libs using pip by vendoring them as explained here.
There are also a number of libraries included in the python27 runtime which can be requested using the libraries directive in your app.yaml as explained here.
If there's a lib which is not pure python (i.e it uses C extensions) that you want to use in your project, and it's not part of this list, then your only option is to use a flexible VM. If you want to use anaconda, you should consider customizing the runtime for your flexible VM.
So Cloud9 looks really cool, and you can create python files in it, but I can't figure out how to get it to run a Django project. I imported one from my github account into the IDE, but it says I need to install Django (a django.core import error) so I need to help getting going. Any Ideas? Any skeleton projects on the web that I missed that will do this?
After some research and looking for an answer on different blogs and sites I finally found a solution:
Create a new workspace
Execute easy_install django to install Django
Create new Django project python ./../bin/django-admin.py startproject myproject
Start dev server python ./myproject/manage.py runserver $IP:$PORT
Access http://projectname.username.c9.io
Voilà!!!
I hope this helps
Just write commands in shell as it is:
sudo pip install -r requirements.txt (you should have there django)
than
python manage.py runserver $IP:$PORT
you will have app on https://projectname-username.c9.io
You may also have to add the proper path: <workspace_name>-<username>.c9users.io to the ALLOWED_HOSTS list in django_project/settings.py file, as suggested by the error message returned by django server. Tested on Django 2.0