Python bigquery - ImportError: No module named google.apputils - python

I am trying to use the google bigquery python library but whenever I run import bq I get the following error;
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-21-923a4eec0450> in <module>()
----> 1 import bq
/Users/tahirfayyaz/anaconda/python.app/Contents/lib/python2.7/site-packages/bq.py in <module>()
31 import oauth2client.tools
32
---> 33 from google.apputils import app
34 from google.apputils import appcommands
35 import gflags as flags
ImportError: No module named google.apputils
I have installed and even upgraded google-apputils but I still get this error.

The way Google Cloud tools are distributed has changed a bit, you'll be able to download a current version of the software via the Cloud SDK:
* https://developers.google.com/cloud/sdk/
The SDK will install a hermetic environment that contains bigquery as well as all of it's dependencies, like oauth2client and google.apputils. It doesn't use ez-install anymore.
You can add the SDK to your PATH to pick up the current bq.py program.
export PATH=$SDKROOT/platform/bigquery:$PATH
You can add the SDK to your PYTHONPATH if you're trying to import something directly as in your example above.
export PYTHONPATH=$SDKROOT/platform/bigquery:$PYTHONPATH

Related

Cannot import gym_wrapper for ACME, any solution?

Import of acme is successfull, but not able to find gym wrapper class
import acme
from acme.wrappers import gym_wrapper
Error Message while running
ModuleNotFoundError Traceback (most recent call last)
\<ipython-input-4-9d5212a1080d\> in \<module\>()
1 # reinforcement learning
2 import acme
\----\> 3 from acme.wrappers import gym_wrapper
4 from acme.environment_loop import EnvironmentLoop
5 from acme.utils.loggers import TerminalLogger, InMemoryLogger
ModuleNotFoundError: No module named 'acme.wrappers'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
Any alternative api for gym_wrapper in ACME framework?
I think you forget to install dm-acme environment module.
It's clearly stated in the section 3. of installation process
pip install dm-acme[envs]

Google Cloud Natural Language Import Error

I am having a lot of trouble with getting the Google Cloud Natural Language API running. I am trying to run a Python program in Linux on a Google VM. I am also unsure of how to run a full Traceback of the error. The following code is not working:
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types.
On Python 2 I get the error:
Traceback (most recent call last):
File "natlangex.py", line 3, in <module>
from google.cloud.language import enums
ImportError: cannot import name enums
I tried upgrading to Python 3 and when I run Python 3 I get the error:
And I updated to Python 3. One thing that is confusing is that when I run Python 3 the error is a bit different:
Traceback (most recent call last):
File "natlangex.py", line 2, in <module>
from google.cloud import language
ImportError: No module named 'google'
Here are the other things I have tried:
I installed the SDK.
I set export GOOGLE_APPLICATION_CREDENTIALS="apikey.json".
I tried !pip install google-cloud-language
I upgraded pip pip install --upgrade setuptools pip.
I am very lost! Thank you in advance.
It seems that you are using wrong syntax because of the library update, you may refer now to the new one, following [1] and more specifically [2].
It seems that the official Natural Language documentation of Google Cloud is not updated yet [3], but at the end of this documentation you have links to the Python Client Library [1][2] where it explains the changes.
Your imports should be:
from google.cloud import language_v1
from google.cloud.language_v1 import enums
from google.cloud.language_v1 import types
[1] https://googleapis.dev/python/language/latest/api.html
[2] https://googleapis.dev/python/language/latest/gapic/v1/api.html
[3] https://cloud.google.com/natural-language/docs/reference/libraries#client-libraries-usage-python

How to fix "cannot import name 'get_seomoz_data' from 'api' " error in Python

I have tried to get the Alexa ranking for a given website. I used PyPI's seolib library and installed it in my environment using !pip install seolib --user command. After executing alexa_rank = seolib.get_alexa('http://google.com') code line, I got the following error.
ModuleNotFoundError: No module named 'api'
Then I installed api module using !pip install api --user command. Then after I got this import error and I don't have an idea of how to solve this error. Please somebody help on this.
import seolib
alexa_rank = seolib.get_alexa('http://google.com')
print(alexa_rank)
ImportError Traceback (most recent call last)
<ipython-input-21-b46efa0fce9a> in <module>
----> 1 import seolib
2
3 alexa_rank = seolib.get_alexa('http://google.com')
4 print(alexa_rank)
~/.local/lib/python3.7/site-packages/seolib/__init__.py in <module>
4
5
----> 6 from api import get_seomoz_data
7 from api import get_alexa
8 from api import get_semrush
ImportError: cannot import name 'get_seomoz_data' from 'api' (/home/mylap/.local/lib/python3.7/site-packages/api/__init__.py)
I'm using Python 3.7.3 version on my environment.
seolib version 0.1.3, last release was in 2013 year. Homepage returns error 404. Doesn't look good. Old, outdated, abandoned.
The code from api import was relative import in Python 2.7, changed to absolute import in Python 3. Overall the code seems to be Python2-only.

How to import google's taskqueue library in python

I am trying to use google task queues in python3, but I am facing some trouble while importing taskqueue library. On issuing the following command
from google.appengine.api import taskqueue
I am getting this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.appengine'
I have installed Google Cloud SDK and additionally installed 2 more packages as mentioned in the link.
google-cloud-sdk-app-engine-python
google-cloud-sdk-app-engine-python-extras
I have checked the version of gcloud components that has been installed
$ gcloud --version
Google Cloud SDK 206.0.0
alpha 2018.06.18
app-engine-python 1.9.70
app-engine-python-extras 1.9.70
beta 2018.06.18
bq 2.0.34
core 2018.06.18
gsutil 4.32
Why I cannot be able to import taskqueue, Any help would appreciated.
The Task Queue service has limited availability outside of the App Engine standard environment. This issue was reported at, please deploy an App Engine standard app to test this out. You can find sample code at.

How to link libraries for python module?

I am trying to install a python module called tables, which depends on HDF5. I have installed HDF5 using pkgsrc, so the libraries and headers are in /usr/pkg/lib and /usr/pkg/include, respectively. This is on a Mac (OS 10.9.4).
I am able to install the tables module using pip only if I first export HDF5_DIR=/usr/pkg. That's not a problem in and of itself, but after pip says it has successfully installed tables, I still can't import the module and the error message seems to indicate that it can't find a library related to HDF5. Please see the error message below. I'm guessing that the hint in the error is 2): Symbol not found: _H5E_CALLBACK_g
In [1]: import tables
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-389ecae14f10> in <module>()
----> 1 import tables
/Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/__init__.py in <module>()
80
81 # Necessary imports to get versions stored on the cython extension
---> 82 from tables.utilsextension import (
83 get_pytables_version, get_hdf5_version, blosc_compressor_list,
84 blosc_compcode_to_compname_ as blosc_compcode_to_compname,
ImportError: dlopen(/Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so, 2): Symbol not found: _H5E_CALLBACK_g
Referenced from: /Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so
Expected in: flat namespace
in /Users/gregory/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/tables/utilsextension.so

Categories