I am relatively new to Python and I am stuck on something which is probably relatively easy to resolve.
I have installed the following packages:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
pip install --upgrade google-cloud-vision
In my Python file I have:
import cv2
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
...etc...
And this gives me the error:
Traceback (most recent call last):
File "test.py", line 6, in <module>
from google.cloud import vision
ImportError: No module named 'google.cloud'
What am I missing and where should I look (logs?) to find the answer in the future.
PS:
Pip installs of google-cloud and google-cloud-vision have the output:
Cannot remove entries from nonexistent file /Users/foobar/anaconda/lib/python3.5/site-packages/easy-install.pth
UPDATE:
Running pip freeze doesn't show the packages to be installed...
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
You need to download and install the google-cloud-sdk. Follow this link https://cloud.google.com/sdk/docs/
try this :
from google.cloud.vision import *
Related
Here's the part that involves the use of skimage in the code:
from skimage import metrics
....
print(metrics.mean_squared_error(gray_frame, canny_img))
print(metrics.peak_signal_noise_ratio(gray_frame, canny_img))
Here's the error:
C:\Users\user\Desktop>python cannyopencv2.py
Traceback (most recent call last):
File "cannyopencv2.py", line 6, in <module>
from skimage import metrics
ImportError: cannot import name 'metrics' from 'skimage' (C:\ProgramData\Anaconda3\lib\site-packages\skimage\__init__.py)
Please help me get rid of it.
Try to install latest version of skimage because that version does not have that module in it so use below command to upgrade it!
pip install scikit-image -U
or
pip install scikit-image --upgrade
You need to install the package first in order to use it.
pip install scikit-image or pip3 install scikit-image
docs
I can't import correct Firebase package in Raspberry PI.
My code:
from firebase import firebase
db = firebase.FirebaseApplication("https://xyz.firebaseio.com/", None)
Error:
Traceback (most recent call last):
File "datastorage.py", line 1, in <module>
from firebase import firebase
firebase/__init__.py", line 14, in <module>
import python_jwt as jwt
ModuleNotFoundError: No module named 'python_jwt'
I tried to use this commands and it didn't help:
sudo pip install requests
sudo pip install python-firebase
pip install jwt
I use Python 3.7.3 and Raspbian Buster. All works on my PC but not on RPi 3B+.
I used advice from #naive.
pip install python_jwt
After that I solved another errors in that order:
pip install gcloud
pip install sseclient
pip install pycrypto
pip install requests-toolbelt
And now I see that It works. Problem was solved.
I think you need python_jwt instead of jwt. You can do:
pip install python_jwt
If you're referring to this library:
https://pyjwt.readthedocs.io/en/latest/
Then you need to install like this:
pip install PyJWT
And afterwards this will work:
import jwt
I'm trying to follow along a tutorial on pulling in Google Analytics data using Python.
Having followed the steps throughout the tutorial, when I call the script I get the error message in the title:
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredential
Traceback (most recent call last):
File "ga.py", line 4, in
from oauth2client.service_account import ServiceAccountCredentials
ImportError: cannot import name 'ServiceAccountCredentials' from 'oauth2client.service_account'
I was reading this SO post after some Googling.
I tried changing my package version:
pip install oauth2client==1.5.2
I tried adding new packages per the answers on that post:
pip install pyopenssl
pip install pycrypto
pip install httplib2
pip install oauth2client
pip install ssl
In each case I encountered the same message after trying to run ga.py:
(zen_ga) Macs-MacBook:zen_ga macuser$ python ga.py
Traceback (most recent call last):
File "ga.py", line 4, in
from oauth2client.service_account import ServiceAccountCredentials
ImportError: cannot import name 'ServiceAccountCredentials' from 'oauth2client.service_account'
How can I import ServiceAccountCredentials from oauth2client.service_account?
First, the class you are trying to import is called ServiceAccountCredentials, not ServiceAccountCredential. So try this instead: from oauth2client.service_account import ServiceAccountCredentials.
oauth2client 1.5.2 does not include ServiceAccountCredentials. Use a more recent version to use it - the latest version is 4.1.3.
Finally, you should note that oauth2client is deprecated, and it is now recommended to use google-auth instead.
My 2cents:
For this to work I had to install and update these packages either
-from WITHIN the NORMAL TERMINAL with PLAIN PYTHON, no distribution such as Conda(dont forget to set Path-Variable):
py -m pip install google-api-python-client
py -m pip install oauth2client
-or from WITHIN the CONDA TERMINAL with:
pip install google-api-python-client oauth2client
pip install --upgrade oauth2client #important
this did NOT WORK when I tried to install and update from jupyter notebook with pip
It works if you import the module alone and then call the class in your code.
Change the import line to:
from oauth2client import service_account
and call the class with the module prefixed like so:
service_account.ServiceAccountCredentials()
i'm trying to run this bot https://github.com/ItsCEED/Youtube-Comment-Bot
in mac os but i get this error
l:Youtube-Comment-Bot-master ROOTXX$ python yt.py
Traceback (most recent call last):
File "yt.py", line 6, in <module>
import google.oauth2.credentials
ImportError: No module named google.oauth2.credentials
l:Youtube-Comment-Bot-master ROOTXX$
Run in a root terminal:
pip install --upgrade google-api-python-client
From here, found with a google search.
EDIT: Even better, you linked the required libraries yourself. They are in the GitHub README.md at here. Please read your own links. Anyway, the commands to install follow:
# pip install --upgrade google-api-python-client
# pip install --upgrade requests
# pip install --upgrade beautifulsoup4
I have Python 2.7.9 with azure-2.0.0rc4 and msrest-0.4.0. My code failed to import from msrest.authentication. I checked the two files from azure and msrest packages, and could not find any issues.
Appreciate any advice and direction.
John
Traceback (most recent call last):
File "getCredential.py", line 1, in <module>
from azure.common.credentials import ServicePrincipalCredentials
File "/usr/local/lib/python2.7/site-packages/azure/common/credentials.py", line 25, in <module>
raise ImportError("You need to install 'msrest' to use this feature")
ImportError: You need to install 'msrest' to use this feature
This seems to be a bug with the pip install --pre azure.
Running this command afterwards installs the necessary packages:
pip install msrestazure
I found the issue. When I sudo pip install, read permission was not set for the others group. Once I fixed that, the issue went away.