ModuleNotFoundError: No module named 'icalendar' google Cloud - python

I'm getting "ModuleNotFoundError: No module named 'icalendar' " after running google app deploy on Gcloud, I have installed the icalendar module using pip but to my surprise i'm getting an error when I try to deploy the app. I have spent hours on this your help will be much appreciated.

According to the official documentation :
Specifying Dependencies
Dependencies for Python applications are declared in a standard
requirements.txt
For example:
Flask==0.10.1
icalendar
Therefore I created a requirements.txt and included icalendar module. Then I deploy to App Engine gcloud app deploy and everything worked as expected.
You can follow this tutorial for better understanding the concept:
Quickstart for Python 3 in the App Engine Standard Environment

Pls. check pip list to see if that has been installed properly. If yes, pls. check that import statement in the python terminal.
If that works, then use which python and ensure that it is the same virtual environment where you are installing and running from.

Related

Can't run the module flask in python

I've been trying to run a code from the internet but I get this error that says:
in
from flask import Flask
ModuleNotFoundError: No module named 'flask'
This is supposed to be a referrence to something i need to work with and i don't know how to fix this as it's not my code.
Here's the link to the code where i got it from:
https://www.geeksforgeeks.org/create-simple-blockchain-using-python/
I just need to run it once so that i could get working on my stuff too.
Edit: i use the basic idle from python btw...
Maybe you dont have flask installed in your dev environment. Do
pip install Flask
or
pip3 install Flask
to install flask

Integrating Python Heroku with Firebase

In a django project I have imported firebase_admin and it worked perfectly on local host, but when I used Heroku to host my web app it gave error no module named 'firbase-admin'. I cross-checked my requirements files and it has firbase-admin. I don't know what's that I did wrong as I made sure that requirements used in virtual environment is same to that in Heroku requirements files.
make sure firebase-admin==4.3.0 is in your requirements.txt file and try not to generate dependencies manually because you can missout on some libraries preferably use pip freeze > requirements.txt

Can Google Cloud Endpoints work with Text To Speech?

I'm trying to keep my Google Cloud project centered around App Engine (GAE) Standard Environment by running a UI in GAE Python 2.7 and then deploying an OpenAPI to Cloud Endpoints which also uses Python 2.7. I want my API to be able to check Google Cloud Storage (GCS) for a file, and then if it doesn't exist, fetch an Entity from Datastore, process some data with Text-
to-Speech, and then save resulting mp3 to GCS.
Under Python 2.7, I need to use the old (2015) cloudstorage client library, google-endpoints, google-endpoints-api-management and google-cloud-texttospeech modules, all in my ./lib folder.
With these modules installed, I can run the "echo" demo project without problem. This indicates that there are no dependency version conflicts. However, when trying to use texttospeech, i get this error:
ImportError: No module named grpc._cython.cygrpc
To fix this, I add the following to the libraries section of app.yaml:
- name: grpcio
version: latest
I then get this error:
from six.moves import http_client
ImportError: No module named moves
I try to fix it similarly, but the error persists
- name: six
version: latest
Other solutions didn't help. six 1.12.0 is installed in ./lib, and 1.11.0 comes with the latest gcloud cloud SDK (233.0.0).
How can I use text-to-speech with Cloud Endpoints? Even if i get this working, can I expect it to work with GCS and Datastore? So far, using Flask-RESTful under GAE seems easier.
These client libraries do not work with the first-generation Python 2.7 runtime, and there are no plans to support them.
You will need to use the new second-generation Python 3.7 runtime instead, which will let you install arbitrary dependencies. See "Python 3 Runtime Environment" for more details.
I think the answer is that Google Cloud Client Libraries aren't yet compatible with Google App Engine. The problem I had here persisted when trying to use Text To Speech in a GAE app even though it worked fine when running little tests locally outside of a GAE app.
This issue can be tracked here:
https://github.com/googleapis/google-cloud-python/issues/1893

Importing mysql.connector into Azure Flask Project

I'm trying to deploy a Flask web app with mysql connectivity. It's my first time using Azure, and coming off Linux it all seems pretty confusing.
My understanding is that one includes within the requirements.txt to include the packages required. When I build the default Flask app from Azure the file looks like this:
Flask<1
At this stage the site loads fine.
If I then include an additional line
https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.14.tar.gz
As per this answer https://stackoverflow.com/a/34489738/2697874
Then in my views.py file (which seems to be broadly synonymous to my old app.py file) I include...import mysql.connector
I then restart and reload my site...which then returns the error The page cannot be displayed because an internal server error has occurred.
Error logging spits out a load of html (seems pretty weird way to deliver error logs - so I must be missing something here). When I save to html and load it up I get this...
How can I include the mysql.connector library within my Flask web app?
Per my experience, the resoure https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.14.tar.gz is for Linux, not for Azure WebApps based on Windows, and the link seems to be not available now.
I used the command pip search mysql-connector to list the related package. Then, I tried to use mysql-connector instead of mysql-connector-python via pip install, and tried to import mysql.connector in local Python interpreter that works fine.
So please use mysql-connector==2.1.4 instead of mysql-connector-python== in the requirements.txt file of your project using IDE, then re-deploy the project on Azure and try again. The package will be installed automatically as the offical doc said as below.
Package Management
Packages listed in requirements.txt will be installed automatically in the virtual environment using pip. This happens on every deployment, but pip will skip installation if a package is already installed.
Any update, please feel free to let me know.

Accessing BigQuery on Google App Engine dev server

I am successfully able to get BQ data from one project to another from the advice in this answer. However this only works when deployed on my development/staging instance and not my local development server on Google App Engine.
My findings are that it works in production because you include:
libraries:
- name: pycrypto
version: "latest"
in app.yaml. However these libraries are not accessible from the dev server. I have tried installing everything locally (Pycrypto, oauth2client, openSSL) after digging through some docs and tracing the error but still cannot get it to work. I have tried installing through pip and manually doing the build/install from the raw files to no avail. Any advice on getting these queries to work on the local django server? Working on Ubuntu if that matters, perhaps it's looking in the wrong spot for the libraries?
If its just the libs that are mising follow this answer https://stackoverflow.com/a/11405769/3877822 to insatll pycrypto to the root of your project
As #Udi suggests in the comment below, the following command also
installs pycrypto and can be used in virtualenv as well:
easy_install
http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win32-py2.7.exe
Notice to choose the relevant link for your setup from this list

Categories

Resources