Downloading and importing Google Cloud Python - python-2.7

I'm on their github page: https://github.com/GoogleCloudPlatform/google-cloud-python
Their first command is pip install --upgrade google-cloud
this gives me:
Collecting google-cloud
Could not find a version that satisfies the requirement google-cloud (from versions: )
No matching distribution found for google-cloud
I downloaded their SDK and which installed their google cloud SDK and I did gcloud init, but I can't seem to have their python library imported into mine. Starting python and typing:
from google.cloud import datastore
gives me an error that it doesn't exist as a module... This is all from their github so I'm not sure what I'm doing wrong

The issue is that the team is trying to transition from gcloud to google-cloud which is still somewhere incomplete.
All you need to do is install gcloud using pip and you should be fine.
Pro Tip: python -m pip install --upgrade gcloud using this command will install it for your python version.

First, make sure you have installed gcloud on your system then run the commands like this:
First: gcloud components update in your terminal.
then: pip install google-cloud
And for the import error:
I had a similar problem. Adding "--ignore-installed" to my pip command made it work for me.
This might be a bug in pip - see this page for more details: https://github.com/pypa/pip/issues/2751

Related

AWS Boto3 Compatibility Issue, How can I install an older version of Boto3?

I'm trying to deploy my Django project to AWS Elastic Beanstalk.
The tutorial I am following is suggesting I use Boto3 to link up my S3 Database.
The problem is when I am installing Boto3 i am getting this message in red.
awsebcli 3.20.3 requires botocore<1.24.0,>1.23.41, but you have botocore 1.27.7 which is incompatible.
So I'm trying to install the older version of Botocore, 1.24.0 or 1.23.41, but after looking at PyPi I can't seem to find it since it just says use pip3 install boto3.
Any suggestions?
Try the following:
pip install boto3==1.21.21
pip install botocore==1.24.21
I had the same problem:
If you already installed boto3 then do these:
pip uninstall boto3
pip uninstall botocore
pip uninstall s3transfer
then do these:
pip install botocore==1.23.54
pip install boto3==1.20.54
Hope this helps!
The best way to fix this is to use python virtual environments.
The AWS EB CLI is pegged to a very specific version of botocore and they don't update it very often. As a result, you don't want it to be in the mix for your project dependencies because it will make it hard for you to install other libraries (like modern versions of boto3).
A general setup that you can use is the following:
Install awsebcli globally (you only need it for its scripts)
Make a virtual environment for your project
Install all of your project dependencies in the virtual env; do not install awsebcli in the virtual env
If this doesn't work (such as you have other things you need to install globally with conflicting subdependenceis), you should install awsebcli in its own virtual env and have aliases to activate it, but that gets really messy.

Google Cloud Machine Learning Engine issue while launching a training job

I want to train an object detector using Google Cloud Machine Learning Engine and I'm stuck while launching the training part of this tutorial.
I'm facing this error :
gapic-google-cloud-logging-v2 0.91.3 has requirement google-gax<0.16dev,>=0.15.7, but you'll have google-gax 0.12.5 which is incompatible.
even after doing
pip install --upgrade setuptools
pip install --upgrade google-gax
Have you got a solution to fix this problem ?
There's a workaround noted in one of the issues of a Google CloudML sample, that switching to pip3 and python3 allows it to be installed.

ModuleNotFoundError: No module named 'flask_openid' (for Python3.6)

I was trying to run a Flask project using Python 3.6.
I encountered an error:
...
from flask_openid import OpenID
ModuleNotFoundError: No module named 'flask_openid'
Flask-OpenID is available in my Python v3.5 dist-packages.
(When I run:
"sudo pip3 install Flask-OpenID", it shows
"Requirement already satisfied (use --upgrade to upgrade): Flask-OpenID in /usr/local/lib/python3.5/dist-packages" )
What should I do to install openid for Python 3.6?
The documentation states that you should import OpenID as follows:
from flask.ext.openid import OpenID
The package itself is installed correctly (in your Python3.5 environment), as shown by pip when you try to install it again:
Requirement already satisfied (use --upgrade to upgrade): Flask-OpenID in /usr/local/lib/python3.5/dist-packages
However, as you state the in your question:
I was trying to run a Flask project using Python 3.6
You might want to make sure your python3 and pip3 are actually pointing to where you want them to, e.g. on your terminal:
$ ls -l $(which pip3)
Or even better, you should really look into creating virtualenvs for your projects, it helps a lot avoiding these kinds of problems in the first place:
create a new Python 3.6 virtualenv
activate your new virtualenv
install your requirements with pip inside the virtualenv
Then run your script in this virtualenv, and you'll be sure you are using exactly the Python you want, and your dependencies are where you expect them to be (and only there, not somewhere else messing up other projects).
Now this might look like a lot of effort, but it takes no more than a couple minutes the first time you do it, will quickly become second nature, and save you a ton of headache down the road.
For me,
python3.6 -m pip install flask_openid
solved the issue.
The above command will install openid for python3.6.

pip installation error for tensorflow

I was trying to install tensorflow from source on ubuntu 14.04, python 2.7.
I followed the steps from "tensorflow.org" for source installation.
I had completed all the steps, such as bazel installation, python dependencies installation.
In the final step for sudo pip installation; the command was as follows:-
$sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0rc0-cp27-none-linux_x86_64.whl
but i am getting error as follows:
Unpacking /tmp/tensorflow_pkg/tensorflow-1.3.0rc0-cp27-none-linux_x86_64.whl
Downloading/unpacking tensorflow-tensorboard (from tensorflow==1.3.0rc0)
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement tensorflow-tensorboard (from tensorflow==1.3.0rc0)
Cleaning up...
No distributions at all found for tensorflow-tensorboard (from tensorflow==1.3.0rc0)
Storing debug log for failure in /home/ubuntu/.pip/pip.log
i also checked tensorflow_pkg wheel :but the above package was not available there.
so can a different .whl can be insatlled using pip such as -tensorflow-1.2.1-cp27-none-linux_x86_64.whl
which have downloaded in my desktop.
Please tell me how i can resolve this issue.
Thanks and regards
I didn't figure out the root of the problem, but for what its worth I skipped the tensorboard issue by installing an older version (1.2.0 worked for me)
pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl
Try:
pip install tensorflow
If that doesn't work:
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp27-none-linux_x86_64.whl
More info here and Common problems here.
My issue was resolved by following steps.
I updated the pip using
Also exported proxy settings.
e.g export https_proxy=...
This was able to resolve my issue.
I also tried installing other .whl file for tensorflow and yes tensorflow can be installed using the downloaded .whl file also.
Thank you

How do I install extra python packages on Datalab if they are not supported by pip?

I tried to install basemap within Datalab using pip:
%bash
pip install basemap
and got the error:
Downloading/unpacking basemap
Could not find any downloads that satisfy the requirement basemap
Cleaning up... No distributions at all found for basemap
Storing debug log for failure in /root/.pip/pip.log
How do I install extra packages on Datalab if they are not supported by pip?
Use apt-get install. In a cell of your notebook:
%bash
apt-get -y update
apt-get -y install python-mpltoolkits.basemap
Then, remember to restart your kernel (by Reset Session)
Use the following code for this:
%%bash
pip install package_name
You might need to first do
apt-get update
So it gets the updated list of packages.
Basemap doesn't come with the google datalab out of the box.
Note: I use shorthand '!' to indicate a bash command, rather than '%bash' as the google documents usually do.
As of Feb 2019, this works on a fresh google datalab:
Step 1: Install Pre-requisites
!apt-get update && apt-get install -y --allow-unauthenticated build-essential libgeos-3.5.0 libgeos-c1v5 libgeos++-dev
!pip install pyproj pyshp
Step 2: Install the whole package
!pip install https://downloads.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz
Step 3: Check the package has been installed correctly
!pip freeze
Step 4: Import the module
from mpl_toolkits.basemap import Basemap
#Lak: You will need to update page 155 of your book - Data Science on the Google Cloud platform as the instructions there won't work; basemap is one of the more difficult packages to get working.
The command suggested by Lak might have worked in the past but it's no longer the case: as of today (Aug 2017) Google Datalab instances reject the command listed here
%bash
echo 'Y' | apt-get install python-mpltoolkits.basemap
outputs the error message:
E: Unable to locate package python-mpltoolkits.basemap
E: Couldn't find any package by regex 'python-mpltoolkits.basemap'
Execution from the shell (vs. notebook) outputs the same error.
After searching various sources I found a fix that worked for me: from the notebook in Datalab I added an update cmd before the actual install, like this:
%bash
echo 'Y' | apt-get update
echo 'Y' | apt-get install python-mpltoolkits.basemap