I am facing some issue with deploying a custom package (to be more specific 2checkout https://github.com/2Checkout/2checkout-python ) in a Django Project via Google App Engine.
As in order to deploy, we do need a file requirements.txt to be included with the python package dependencies (which can be installed via pip), but in the case of a custom package (like the above mentioned), how can we implement the custom package in Google App Engine.
If you're using the standard environment you can install the package into your application locally so that it's deployed as part of your app. From Private dependencies:
Dependencies are installed in a Cloud Build environment that does not
provide access to SSH keys. Packages hosted on repositories that
require SSH-based authentication must be copied into your project
directory and uploaded alongside your project's code using the
pip package manager.
To use private dependencies:
Run pip install -t lib my_module to copy dependencies into a local
folder named lib.
Add an empty __init__.py file to the lib directory to make it a
module.
Import the module in your app. For example:
import lib.my_module
If you're using the flexible environment you can build a custom runtime, see Deploy Python app with textract module to Google Cloud Platform.
Related
I have a python package in a private GitHub Repo. While using it locally I use
pip install git+https://git#github.com/org-name/package-name.git
in the bash to install the package.
I want to use that package in my azure functions and container apps. Is there a way to add that package to the requirements file and install it? And what do I need to configure in Github so that my azure resources can access it?
I add git+https://git#github.com/org-name/package-name.git to requirements.txt of the azure function app and I am unable to run it even locally.
I get the following error:
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q 'https://****#github.com/org-name/packagename.git'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
You can setup a CI/CD pipeline in Azure Devops or github action that :
Triggers whenever there is a pull request in github master.
Copy the python submodules in azure function and container apps code.
You have to package your code install allow it to be installed using
pip install git+ssh://github.com/yourprofile/project.git
I am attempting to deploy a Django app to a Linux server via an Azure App Service. During the deployment via Azure Devops Pipelines, all requirements are installed from my requirements.txt file in the root directory of my project.
I have used the Kudu console to confirm the dependencies are installed to /antenv/lib/python3.7/site-packages on the server, however, the app crashes due to an error:
ModuleNotFoundError: No module named 'django'
I am beginning to think the virtual environment may be failing to actually start but do not know how to check or how to start it if this is the case.
Has anyone had a similar issue to this during their deployment? If so how did you resolve it? Any advise is much appreciated. Thank you!
Newest
Change target path ,--target="./.python_packages/lib/site-packages" .
- bash: |
python3.8 -m venv worker_venv
source worker_venv/bin/activate
pip3.8 install setuptools
pip3.8 install --target="./.python_packages/lib/site-packages" -r requirements.txt
displayName: 'Install Application Dependencies'
You need to install a new Python runtime at the path D:\home via Kudu site extensions.(Windows)
The problems is, azure app service use virtualenv by default, so the requirements.txt package is automaticly installed to python in the virtualenv... so I just edit the deploy.cmd to install requirements to python (extension)
For more details, you can refer Peter Pan's answer in below post.
Why is the azure app service django deploy keep failing?
I am trying to run dev_appserver.py on this Google App Engine Standard Flask Sample
As the instructions say I run:
pip install -t lib -r requirements.txt
dev_appserver.py app.yaml
I should be able to go to http://localhost:8080/form but I get ImportError: No module named msvcrt.
I found that using Flask==0.10.1 and Werkzeug==0.12.2 works but nothing newer.
Versions:
OS: Windows 10 Pro
Python 2.7.14
Google Cloud SDK 182.0.0
app-engine-go
app-engine-python 1.9.63
app-engine-python-extras 1.9.63
bq 2.0.27
core 2017.12.01
gsutil 4.28
I have tried the example myself from the Cloud Shell, and I also found some issues with the imports. It looks like newer releases of Werkzeug have transferred code to different locations, so as suggested in this recent post if you want to use the example as it is, you should better work with the version 0.12.2 of Werkzeug.
To do so, I recommend you the following steps:
Delete the lib file in the directory of the application, and all of its content.
Edit the requirements.txt file to be as follows:
requirements.txt:
Flask==0.12.2
werkzeug==0.12.2
Run again the command pip install -t lib -r requirements.txt.
Now you can try running your application locally with the dev_appserver. Please make sure that the appengine_config.py file is pointing to the proper location of the lib folder where the libraries are being installed.
Once you have done all that, everything should be working fine. I have tried browsing for the localhost URL you mentioned and a simple HTML page with a form appears.
In Azure, using Python with the Flask and pandas modules to create a RESTful webservice. Azure doesn't appear able to find the requests_file module.
Launching the web page keeps returning error: No module named requests_file
I have installed "requests" and "requests_file" manually using the Kudu CLI https://"yoursitename".scm.azurewebsites.net/DebugConsole.
They both appear to be there. What am I missing or is there a bug in Azure?
You could configure your requirements.txt file in your flask project.
Put the list of your python modules in the requirements.txt
requests==2.18.4
Install wheel module using below command
python.exe -m pip install wheel
Use Below Command to create wheel files inside wheelhouse folder in Local environment
python.exe -m pip wheel -r requirements.txt -w wheelhouse
Then upload your project to your azure web app.
You could use code as below to test requests module
import requests
r= requests.get("https://www.bing.com")
print r.status_code
More details , please refer to this blog and this thread: Publishing MVC app that uses python script
Hope it helps you.
I am on Mac OS and developing for google cloud platform.
I have created vitualenv - virtualenv xyz.
I activated using - source xyz/bin/activate
Then, I installed the pkg I needed - pip install python-dateutil
When I do pip list, I do see the python-dateutil is there
But when i run my service using dev_appserver.py . and try to make a post request. I get the ImportError: No module named dateutil.parser
Questions: In my appengine_config.py, I have vendor.add('lib') but the packages are installed under my_project-> xyz -> lib -> python2.7 -> site-packages -> dateutil. How does my app knows where to look for packages?
Second question: When I am ready to deploy to production, how do I deploy the packages. pip freeze > requirements.txt. Is that enough for prod server to know what packages to use. Do I need lib folder under my_project? I am confused about how packages get referred in virtualenv and in production.
You're mixing the instructions for installing dependencing for the standard environment with those for the flexible environment. Related: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment
You're using dev_appserver.py so I assume your app is a standard environment one, in which case you need to install the library into your app (note the -t lib arguments), not on the system/venv. Assuming you execute from your app's dir:
pip install python-dateutil -t lib