Import error for google api client in django project - python

I am running django version 1.10.3 and I installed google api client with pip like so:
pip install --upgrade google-api-python-client
When I try to use it with PyCharm/Terminal outside of a django project it works just fine. However, when I try to import it in my django project it throws this error:
ImportError: No module named googleapiclient
For this import statement:
from googleapiclient import discovery
I don't use any virtual env and nothing. Does anybody know why this error occurs?
Thanks in advance!

Related

reportMissingImports Python error but import works fine

When I install package with python and import it, I often get a missing imports message such as:
Import "fastapi" could not be resolvedPylancereportMissingImports
The imports always work perfectly fine, the fastapi example above will run a server and I can build an API without issue.
Can anyone explain why I am getting this error and how I could get rid of it?
Reinstall fastapi again separately.
pip install 'fastapi[all]'
pip install fastapi
pip install uvicorn

Python Flask_MYSQLDB problems

Hi
I have been following a step by step on how to make a login system with python, with flask-mysqldb. I'm trying to run the python script, but i end up getting a error message that i don't understand so much of.
from flask import Flask, render_template, request, redirect, url_for, session
from flask_mysqldb import MySQL
import MySQLdb.cursors
import re
app = flask(__name__)
When I'm trying to run the script, on the localhost page it also shows a error, I have copyed and pasted te error in pastebin. When I try to install the flask_mysqldb i get a error in my cmd. Here is what my cmd says.
I have google with parts of the error, trying to find some information about what the problem can be. And tryed to pip install a lot for things that some people have said that can work, without any luck. And can't figure out how to get this to work.
I also tryed to install Anaconda terminal to run the command in there for installing flask_mysqldb, but no luck. Tryed to uninstall and reinstall everything, but nothing changed the error i get.
The error:
ModuleNotFoundError: No module named 'flask_mysqldb'
indicates that the module has not been installed or installed in a wrong environment.
Install it using:
pip install flask-mysqldb
The stack from from the error
File "c:\users\chris\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "C:\xampp\htdocs\pythonlogin\main.py", line 2, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
is indicating that Python 3.7 in involved.
In this case, using pip to install flask_mysqldb will lead to grief. Use pip3 instead. E.g.,
pip3 install flask_mysqldb

In what python library is google.cloud?

I've used pip (and pip3) to install google-api-python-client, all over the place, but whenever I try to issue
from google.cloud import bigquery
I get an
ImportError: No module named google.cloud" error.
sys.path contains the directory that pip reports google-api-python-client is installed in, although it's near the end of a long(ish) list of directories.
Edit:
I've also installed google-cloud. The error occurs with both libraries installed.
Edit2: the Location for both are: "/home/swood/.local/lib/python3.5/site-packages"
print(sys.path) returns: ['/mnt/pasnas00/dbdata/snowflakedata/lib', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/swood/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
That's because those are different libraries. You have installed the Google API Client and trying to import the Google Cloud one. For an overview of the differences you can refer to this documentation.
Install it with this instead:
pip install google-cloud
or with pip3 for Python3. If you still want to use the other Client you'll need to import it and build the BigQuery service with something like this:
from googleapiclient.discovery import build
...
service = build('bigquery', 'v2', credentials=credentials)

trouble with importing gcloud libs in python script

I have updated gcloud components. I have installed BigQuery lib using pip install following the instructions in the online doc. I am running Python 2.7.10.
when I run a python script that has the following line:
from google.cloud import bigquery
it returns the following error:
ImportError: No module named google.cloud
I tried python 3.6 and still get the same error.
I did reintsall google sdk and still got the same error.
if I do touch /Library/Frameworks/Python.framework/Versions/2.7/lib/python‌​2.7/site-packages/go‌​ogle/init.py then import google woudl work, but not import google.cloud
any help is appreciated.
The Cloud SDK is not enough. Just use pip install --upgrade google-cloud-bigquery, see https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/bigquery

PyMongo and Flask on Linux server

I'm trying to connect to connect to my MongoDB instance from my FLASK app and I've run into an issue. I followed the tutorial at https://flask-pymongo.readthedocs.org/en/latest/
When I try to run the server I get the following error:
ImportError: No module named flask.ext.pymongo
I've ran pip install Flask-PyMongo.
The code fails when I try to import PyMongo using from flask.ext.pymongo import PyMongo
Turns out the solution to the problem was that I needed to download Flask-PyMongo to my projects local libs folder using pip install -t lib Flask-PyMongo
This is due to the line in my config file vendor.add('lib')

Categories