after runing this code,I found import error:-
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')
application = webapp.WSGIApplication([('/', MainPage)],debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
how to use google.apengine.ext
import sys
sys.path.insert(1, '/Users/<username>/google-cloud-sdk/platform/google_appengine')
sys.path.insert(1, '/Users/<username>/google-cloud-sdk/platform/google_appengine/lib/yaml/lib')
sys.path.insert(1, 'lib')
if 'google' in sys.modules:
del sys.modules['google']
this solves the problems for me
It looks like the App Engine SDK is not installed, or at least the Python runtime cannot find it.
read and follow the instructions here: https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python
They tell you, how to install App Engine SDK for Python.
Try:
import google
print google.__path__
to see what exactly you're importing.
I had this same issue because I pip installed gcloud before downloading and installing the SDK. The pip install created a python package google which didn't contain the appengine submodule (which is found in the SDK folder). I uninstalled the gcloud and related packages. Then just pip installed the google-cloud-bigquery which is the only package I needed from gcloud. Everything works fine now.
I faced similar error while calling Google Analytics API using AWS Lambda.
Workaround from (Schweigi1) helped me.
import googleapiclient
from googleapiclient.discovery_cache.base import Cache
class MemoryCache(Cache):
_CACHE = {}
def get(self, url):
return MemoryCache._CACHE.get(url)
def set(self, url, content):
MemoryCache._CACHE[url] = content
Usage:
service = googleapiclient.discovery.build("analyticsreporting", "v4", http=http, credentials=credentials,cache=MemoryCache())
Hope this helps someone who is facing this issue in AWS Lambda.
First possible reason:
you don't install the python library in google cloud sdk, so you can run in cmd (as administrator):
gcloud components install app-engine-python.
Second possible reason:
your IDE is not success get into google libraries, they exist in:
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine
or in:
C:\Users\[your user]\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine
You can see in attached link explain how to add these libraries to IDE external libraries: https://stackoverflow.com/a/24206781/8244338
I got this error in python:
from google.appengine.api import search
ImportError: No module named appengine.api
I thought this would be something along the similar lines of what is happening in this thread.
So, my solution was to run "dev_appserver.py 'your yaml file' ". I got this solution following the below links:
1) https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server
2) https://www.youtube.com/watch?v=BdqUY8lCuBI
Hope this helps!
check if you named some file google.py :) in the same package, because this can shadow the import of google.appengine.ext. I had the same error:
python import error “No module named appengine.ext”
and deleteting the file solved the problem.
Related
I build a google translate application and it was running fine in pycharm. When I converted the files into single executable file using pyinstaller the executable file is not running. I have imported from google.cloud import translate_v2
Error message is noted below:
pkg_resources.DistributionNotFound: The 'google-cloud-translate' distribution was not found and is required by the application
Please help where went wrong.Let me know if any other details required
Add this parameter to the command line when running pyinstaller:
--copy-metadata google-cloud-translate
But actually, if you use a newer PyInstaller version, the automatic bytecode scanning should do that for you.
Thanks. I have solved the issue by editing the code in the below path
C:\Users\3888123\AppData\Local\Programs\Python\Python39\Lib\site-packages\google\cloud\translate_v2_init_.py
From
from pkg_resources import get_distribution
__version__ = get_distribution("google-cloud-translate").version
from google.cloud.translate_v2.client import Client
__all__ = ("__version__", "Client")
To
__version__ = "4"
from google.cloud.translate_v2.client import Client
__all__ = ("__version__", "Client")
Result
Single executable file created with out error. Hope this answer helps some one.
I've downloaded the looker_sdk for python.
Wrote a very simple program:
from looker_sdk import client, models
def test_looker():
sdk = client.setup("./looker.ini")
if __name__ == "__main__":
test_looker()
However, when I'm running it I'm getting the error:
ImportError: cannot import name 'client' from 'looker_sdk'.
I do see the models and was able to perform:
sdk = looker_sdk.init31()
what am I missing?
Thanks,
Nir.
It seems there may be a missing client.py file in looker_sdk version 0.1.3b8, or in your installation - I tested this on 0.1.3b4 and found no such issue.
I recommend that you uninstall the package and re-install the latest version from PyPI.
I need to work with API via wsdl and I'm trying to figure out how zeep module works. The module was installed with "pip install" and it shows the same error every time.
ImportError: cannot import name 'Client' from 'zeep'
from zeep import Client
client = Client('http://www.webservicex.net/ConvertSpeed.asmx?WSDL')
result = client.service.ConvertSpeed(
100, 'kilometersPerhour', 'milesPerhour')
assert result == 62.137 ```
First of all, do a pip freeze and make sure that zeep is installed.
If it's installed then make sure your source file is not named zeep.py or it will not work.
[edit]
From someone else on Github: "And ensure there's no zeep.pyc in the folder"
This leads me to believe that there should be no source file with the name zeep in the folder.
Link to GitHub discussion
You need to set permissions on the zeep library.
Set permissions on the library directory in the site-packages directory.
chmod -R 777 zeep
When I do :
from oauth2client.client import SignedJwtAssertionCredentials
in my main.py which is served using the App Engine development server, I am getting an error :
ImportError: cannot import name SignedJwtAssertionCredentials
When I ran from a standard python console the same statement, I am not getting any error. The import works fine.
I confirm that I have pyopenssl installed on my system. I have already read this post which suggest only to install it: ImportError: cannot import name SignedJwtAssertionCredentials
Any idea of what's wrong with the development server?
PS : My main goal is to connect to BigQuery
Instead of using SignedJwtAssertionCredentials and deploying your PKCS12 key with your application, you can use AppAssertionCredentials from the oauth2client.appengine package. Ensure that your appengine application service is added to your project and you are good to go.
Looks like a long standing issue with the AppEngine environment: https://code.google.com/p/google-api-python-client/issues/detail?id=133
I am having the same problem as this thread regarding twilio-python:
twilio.rest missing from twilio python module version 2.0.8?
However I have the same problem but I have 3.3.3 installed. I still get "No module named rest" when trying to import twilio.rest.
Loading the library from stand alone python script works. So I know that pip installing the package worked.
from twilio.rest import TwilioRestClient
def main():
account = "xxxxxxxxxxxxxxxx"
token = "xxxxxxxxxxxxxxxx"
client = TwilioRestClient(account, token)
call = client.calls.create(to="+12223344",
from_="+12223344",
url="http://ironblanket.herokuapp.com/",
method="GET")
if __name__ == "__main__":
main()
but this does not work:
from twilio.rest import TwilioRestClient
def home(request):
client = TwilioRestClient(account, token)
Do you have any idea what I can try next?
I named a python file in my project twilio.py. Since that file was loaded first, then subsequent calls to load twilio would reference that file instead of the twilio library.
TLDR: just don't name your python file twilio.py
Check which versions of pip and python you are running with this command:
which -a python
which -a pip
pip needs to install to a path that your Python executable can read from. Sometimes there will be more than one version of pip like pip-2.5, pip-2.7 etc. You can find all of them by running compgen -c | grep pip. There can also be more than one version of Python, especially if you have Macports or brew or multiple versions of Python installed.
Check which version of the twilio module is installed by running this command:
$ pip freeze | grep twilio # Or pip-2.7 freeze etc.
The output should be twilio==3.3.3.
I hope that helps - please leave a comment if you have more questions.
This Worked For me : (Windows)
Python librarys are in G:\Python\Lib
(Python is installed at G:, it might be different for you)
Download Twilio from github at paste the library at >> G:\Python\Lib <<
import problem gone :)
I had the same issue and it drove me crazy. Finally I figured it out. When you get the error:
AttributeError: module 'twilio' has no attribute 'version'
Look 2 lines above and the error is telling you where it expects to find the twilio file. So I moved it from where it was to where it was asking it to be.
Installed to:
c:\users\rhuds\appdata\local\programs\python\python37-32\lib\site-packages
Moved it to:
Traceback (most recent call last):
File "", line 1, in
import twilio
File "C:\Users\rhuds\AppData\Local\Programs\Python\Python37-32\twilio.py", line 2, in
Now I can import twilio. Besides that, the only other thing I did was uninstall old versions of Python, but I don't think that really mattered.