How can I make a python windows service that uses the GPU? - python

Using this link, I was able to create a Windows service using python and it runs great. However, when I try to get it to start utilizing the GPU (to interact with tensorflow) it will not see the GPU inside of the Service class.
Here is code that I am using to test the windows service.
import sys
import os
import os.path
import numpy as np
from PIL import Image
import random
#from scipy.misc import imread, imsave
import tensorflow as tf
from tensorflow import keras
from tensorflow.python.keras.layers import concatenate, Lambda, Input, Dense, Dropout, Flatten, Conv2D, MaxPooling2D, \
BatchNormalization, Activation, GlobalAveragePooling2D, SeparableConv2D, Reshape, Conv2DTranspose
import queue
from queue import Queue
#import keras
import pika
import json
import base64
import time
from six.moves import configparser
import threading
from threading import Lock, Thread
import win32serviceutil
import win32service
import win32event
import servicemanager
import logging
import logging.handlers
log_file = "C:\\loglocation\\GPUService.log"
configLocation="D:\\configlocation\\config.ini"
# Return a logger with the specified name.
mylogger = logging.getLogger("MyLogger")
# Sets the threshold for this logger to lvl. Logging messages which are less severe than lvl will be ignored.
mylogger.setLevel(logging.DEBUG)
# Sets rotation parameters of disk log files
# https://docs.python.org/3.4/library/logging.handlers.html#rotatingfilehandler
handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=10485760, backupCount=2)
# Sets format of record in log file
formatter = logging.Formatter('%(asctime)s - %(module)-10s - %(levelname)-8s %(message)s', '%d-%m-%Y %H:%M:%S')
handler.setFormatter(formatter)
# Adds the specified handler to logger "MyLogger"
mylogger.addHandler(handler)
SEED = 42
np.random.seed(SEED)
random.seed(SEED)
class AAAService(win32serviceutil.ServiceFramework):
_svc_name_ = "AAATestService"
_svc_display_name_ = "Test Service"
def __init__(self, args):
mylogger.info("*** INIT SERVICE ***\n")
win32serviceutil.ServiceFramework.__init__(self, args)
# Create an event which we will use to wait on.
# The "service stop" request will set this event.
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.stop_requested=False
def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
mylogger.info("*** STOP SERVICE ***\n")
# And set my event.
win32event.SetEvent(self.hWaitStop)
self.stop_requested=True
def SvcDoRun(self):
# We do nothing other than wait to be stopped!
mylogger.info("*** STARTING SERVICE ***\n")
self.main()
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
def main(self):
mylogger.info("... Can I see a GPU? ...\n")
mylogger.info(tf.config.list_physical_devices('GPU'))
sys_details = tf.sysconfig.get_build_info()
cuda_version = sys_details["cuda_version"]
mylogger.info("This is my cuda version: " + cuda_version)
cudnn_version = sys_details["cudnn_version"]
mylogger.info("CUDNN_VERSION: "+ cudnn_version)
cuda_compute_capabilities = sys_details["cuda_compute_capabilities"]
mylogger.info(cuda_compute_capabilities)
mylogger.info("... STARTING SCHEDULE PROCESS ...\n")
mylogger.info("... Waiting for reponse messages ...\n")
# while not self.stop_requested:
# # execute task on schedule
# mylogger.info("... task ...\n")
# time.sleep(10)
return
if __name__=='__main__':
if len(sys.argv) == 1:
servicemanager.Initialize()
servicemanager.PrepareToHostSingle(AAAService)
servicemanager.StartServiceCtrlDispatcher()
else:
win32serviceutil.HandleCommandLine(AAAService)
mylogger.info("... 1Can I see a GPU? ...\n")
mylogger.info(tf.config.list_physical_devices('GPU'))
sys_details = tf.sysconfig.get_build_info()
cuda_version = sys_details["cuda_version"]
mylogger.info("1This is my cuda version: " + cuda_version)
cudnn_version = sys_details["cudnn_version"]
mylogger.info("1CUDNN_VERSION: "+ cudnn_version)
cuda_compute_capabilities = sys_details["cuda_compute_capabilities"]
mylogger.info(cuda_compute_capabilities)
mylogger.info("... 1STARTING SCHEDULE PROCESS ...\n")
mylogger.info("... 1Waiting for reponse messages ...\n")
And here is my conda list to show my environment
#
# Name Version Build Channel
absl-py 0.15.0 pypi_0 pypi
altgraph 0.17 pyhd3eb1b0_0
astunparse 1.6.3 pypi_0 pypi
ca-certificates 2021.10.8 h5b45459_0 conda-forge
cachetools 5.0.0 pypi_0 pypi
certifi 2021.10.8 py39hcbf5309_1 conda-forge
charset-normalizer 2.0.12 pypi_0 pypi
flatbuffers 1.12 pypi_0 pypi
freetype 2.10.4 hd328e21_0
future 0.18.2 py39haa95532_1
gast 0.4.0 pypi_0 pypi
google-auth 2.6.0 pypi_0 pypi
google-auth-oauthlib 0.4.6 pypi_0 pypi
google-pasta 0.2.0 pypi_0 pypi
grpcio 1.34.1 pypi_0 pypi
h5py 3.1.0 pypi_0 pypi
idna 3.3 pypi_0 pypi
importlib-metadata 4.11.1 pypi_0 pypi
jpeg 9d h2bbff1b_0
keras-nightly 2.5.0.dev2021032900 pypi_0 pypi
keras-preprocessing 1.1.2 pypi_0 pypi
libpng 1.6.37 h2a8f88b_0
libtiff 4.2.0 hd0e1b90_0
libwebp 1.2.0 h2bbff1b_0
lz4-c 1.9.3 h2bbff1b_1
macholib 1.14 pyhd3eb1b0_1
markdown 3.3.6 pypi_0 pypi
numpy 1.19.5 pypi_0 pypi
oauthlib 3.2.0 pypi_0 pypi
olefile 0.46 pyhd3eb1b0_0
openssl 1.1.1l h8ffe710_0 conda-forge
opt-einsum 3.3.0 pypi_0 pypi
pefile 2019.4.18 py_0
pika 1.2.0 pyh44b312d_0 conda-forge
pillow 8.4.0 py39hd45dc43_0
pip 21.2.4 py39haa95532_0
protobuf 3.19.4 pypi_0 pypi
pyasn1 0.4.8 pypi_0 pypi
pyasn1-modules 0.2.8 pypi_0 pypi
pycryptodome 3.12.0 py39h2bbff1b_0
pyinstaller 3.6 py39h8cc25b3_6
python 3.9.7 h6244533_1
python_abi 3.9 2_cp39 conda-forge
pywin32 302 py39h827c3e9_1
pywin32-ctypes 0.2.0 py39haa95532_1000
requests 2.27.1 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.8 pypi_0 pypi
setuptools 58.0.4 py39haa95532_0
six 1.15.0 pypi_0 pypi
sqlite 3.37.2 h2bbff1b_0
tensorboard 2.8.0 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.1 pypi_0 pypi
tensorflow-estimator 2.5.0 pypi_0 pypi
tensorflow-gpu 2.5.0 pypi_0 pypi
termcolor 1.1.0 pypi_0 pypi
tk 8.6.11 h2bbff1b_0
typing-extensions 3.7.4.3 pypi_0 pypi
tzdata 2021e hda174b7_0
urllib3 1.26.8 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
werkzeug 2.0.3 pypi_0 pypi
wheel 0.37.1 pyhd3eb1b0_0
wincertstore 0.2 py39haa95532_2
wrapt 1.12.1 pypi_0 pypi
xz 5.2.5 h62dcd97_0
zipp 3.7.0 pypi_0 pypi
zlib 1.2.11 h8cc25b3_4
zstd 1.4.9 h19a0ad4_0
When I install or start the service, my log is showing the GPU is appropriately being recognized in the
__main__
function, but when I get to the service class, the GPU is no longer seen.
The service still sees the appropriate version of cuda as well, here is a snapshot from the log
02-03-2022 10:36:09 - GPUService - INFO ... 1Can I see a GPU? ...
02-03-2022 10:36:09 - GPUService - INFO [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
02-03-2022 10:36:09 - GPUService - INFO 1This is my cuda version: 64_112
02-03-2022 10:36:09 - GPUService - INFO 1CUDNN_VERSION: 64_8
02-03-2022 10:36:09 - GPUService - INFO ['sm_35', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'compute_80']
02-03-2022 10:36:09 - GPUService - INFO ... 1STARTING SCHEDULE PROCESS ...
02-03-2022 10:36:09 - GPUService - INFO ... 1Waiting for reponse messages ...
02-03-2022 10:36:11 - GPUService - INFO *** INIT SERVICE ***
02-03-2022 10:36:11 - GPUService - INFO *** STARTING SERVICE ***
02-03-2022 10:36:11 - GPUService - INFO ... Can I see a GPU? ...
02-03-2022 10:36:11 - GPUService - INFO []
02-03-2022 10:36:11 - GPUService - INFO This is my cuda version: 64_112
02-03-2022 10:36:11 - GPUService - INFO CUDNN_VERSION: 64_8
02-03-2022 10:36:11 - GPUService - INFO ['sm_35', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'compute_80']
02-03-2022 10:36:11 - GPUService - INFO ... STARTING SCHEDULE PROCESS ...
02-03-2022 10:36:11 - GPUService - INFO ... Waiting for reponse messages ...
I have another script that is just testing out the GPU within this conda env and it sees the GPU just fine.
I think it has something to do with the changing of context once it enters the service.

Related

Module is not found when trying to import it and running a virtual environment (venv)

I am currently using a virtual environment (venv) with python. The "venv" directory is inside my project folder by standard convention.
My project folder contains multiple different modules.
I have a jupyter notebook that has multiple import statements in the beginning. One of the import statements calls one of my other custom-made modules. This certain module imports tensorflow. When I call pip3 list -V in the terminal, I get:
Package Version
----------------------- ---------
absl-py 0.13.0
anyio 3.3.0
appnope 0.1.2
argon2-cffi 20.1.0
astunparse 1.6.3
attrs 21.2.0
autopep8 1.5.7
Babel 2.9.1
backcall 0.2.0
bleach 4.0.0
cachetools 4.2.2
certifi 2021.5.30
cffi 1.14.6
charset-normalizer 2.0.4
cycler 0.10.0
debugpy 1.4.1
decorator 5.0.9
defusedxml 0.7.1
entrypoints 0.3
gast 0.3.3
google-auth 1.34.0
google-auth-oauthlib 0.4.5
google-pasta 0.2.0
grpcio 1.39.0
h5py 2.10.0
idna 3.2
ipykernel 6.2.0
ipython 7.26.0
ipython-genutils 0.2.0
ipywidgets 7.6.3
jedi 0.18.0
Jinja2 3.0.1
json5 0.9.6
jsonschema 3.2.0
jupyter-client 6.1.12
jupyter-core 4.7.1
jupyter-server 1.10.2
jupyterlab 3.1.7
jupyterlab-pygments 0.1.2
jupyterlab-server 2.7.0
jupyterlab-widgets 1.0.0
Keras-Preprocessing 1.1.2
kiwisolver 1.3.1
Markdown 3.3.4
MarkupSafe 2.0.1
matplotlib 3.4.3
matplotlib-inline 0.1.2
mistune 0.8.4
nbclassic 0.3.1
nbclient 0.5.4
nbconvert 6.1.0
nbformat 5.1.3
nest-asyncio 1.5.1
notebook 6.4.3
numpy 1.18.5
oauthlib 3.1.1
opt-einsum 3.3.0
packaging 21.0
pandocfilters 1.4.3
parso 0.8.2
pexpect 4.8.0
pickleshare 0.7.5
Pillow 8.3.1
pip 21.2.4
prometheus-client 0.11.0
prompt-toolkit 3.0.19
protobuf 3.17.3
ptyprocess 0.7.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycodestyle 2.7.0
pycparser 2.20
Pygments 2.10.0
pyparsing 2.4.7
pyrsistent 0.18.0
python-dateutil 2.8.2
pytz 2021.1
pyzmq 22.2.1
requests 2.26.0
requests-oauthlib 1.3.0
requests-unixsocket 0.2.0
rsa 4.7.2
scipy 1.4.1
Send2Trash 1.8.0
setuptools 49.2.1
six 1.16.0
sniffio 1.2.0
tensorboard 2.6.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.0
tensorflow 2.3.0
tensorflow-estimator 2.3.0
termcolor 1.1.0
terminado 0.11.0
testpath 0.5.0
toml 0.10.2
tornado 6.1
traitlets 5.0.5
urllib3 1.26.6
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.2.1
Werkzeug 2.0.1
wheel 0.37.0
widgetsnbextension 3.5.1
wrapt 1.12.1
However, when I try to import my module that contains tensorflow I get ModuleNotFoundError: No module named 'tensorflow'. We can clearly see that tensorflow has been installed by pip3. What's my problem here?
I am new to programming in general and would appreciate some guidance here. I have looked into the PYTHONPATH variable and am trying to understand it. I am also confused with this since I am implementing a virtual environment here. I am using MacOS.
You may be running your jupyter notebook from a different virtual environment. So if you are running jupyter from conda, you need to shut it down, and start jupyter server from terminal with your venv:
jupyter notebook

Python3 Import Error: undefined symbol: aes_hw_encrypt

I am trying to use DialogFlow to make a small talk chatbot on Raspberry Pi 4, and I am getting this error:
ImportError: /usr/local/lib/python3.7/dist-packages/grpc/_cython/cygrpc.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: aes_hw_encrypt
My code is as follows:
"""
Libraries used:
dialogflow 1.1.0 - I did pip3 install dialogflow -U and it upgraded to this
google-api-core 1.29.0
os Latest version - not sure
"""
import os
import dialogflow
from google.api_core.exceptions import InvalidArgument
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'secrets.json'
DIALOGFLOW_PROJECT_ID = '[test_id]'
DIALOGFLOW_LANGUAGE_CODE= '[en]'
SESSION_ID = 'me'
text_to_be_analyzed = "Howdy"
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
text_input = dialogflow.types.TextInput(text=text_to_be_analyzed, language_code=DIALOGFLOW_LANGUAGE_CODE)
query_input = dialogflow.types.QueryInput(text=text_input)
try:
response = session_client.detect_intent(session=session, query_input=query_input)
except InvalidArgument:
raise
print("Query text:", response.query_result.query_text)
print("Detected intent:", response.query_result.intent.display_name)
print("Detected intent confidence:", response.query_result.intent_detection_confidence)
print("Fulfillment text:", response.query_result.fulfillment_text)
pip3 list gives me:
-------------------------------- ---------------
Adafruit-BBIO 1.2.0
Adafruit-Blinka 6.10.0
Adafruit-CharLCD 1.1.1
adafruit-circuitpython-busdevice 5.0.6
adafruit-circuitpython-framebuf 1.4.7
adafruit-circuitpython-ssd1306 2.11.4
Adafruit-GPIO 1.0.3
Adafruit-ILI9341 1.5.1
Adafruit-PlatformDetect 3.13.3
Adafruit-PureIO 1.1.8
Adafruit-SSD1306 1.6.2
appdirs 1.4.3
asn1crypto 0.24.0
astroid 2.1.0
asttokens 1.1.13
attrs 21.2.0
automationhat 0.2.0
beautifulsoup4 4.7.1
blinker 1.4
blinkt 0.1.2
bs4 0.0.1
buttonshim 0.0.2
cachetools 4.2.2
Cap1xxx 0.1.3
certifi 2018.8.24
chardet 3.0.4
Click 7.0
colorama 0.3.7
colorzero 1.1
cookies 2.2.1
cryptography 2.6.1
cupshelpers 1.0
cycler 0.10.0
decorator 4.4.2
dialogflow 1.1.0
docutils 0.14
drumhat 0.1.0
entrypoints 0.3
envirophat 1.0.0
ExplorerHAT 0.4.2
flake8 3.9.2
Flask 1.0.2
fourletterphat 0.1.0
fuzzywuzzy 0.18.0
google-api-core 1.29.0
google-auth 1.30.1
googleapis-common-protos 1.53.0
gpiozero 1.5.1
grpcio 1.38.0
guizero 0.6.0
html5lib 1.0.1
idna 2.6
imageio 2.9.0
importlib-metadata 4.0.1
iniconfig 1.1.1
ipykernel 4.9.0
ipython 5.8.0
ipython-genutils 0.2.0
isort 4.3.4
itsdangerous 0.24
jaraco.context 4.0.0
jedi 0.13.2
Jinja2 2.10
jupyter-client 5.2.3
jupyter-core 4.4.0
keyring 17.1.1
keyrings.alt 3.1.1
kiwisolver 1.3.1
lazy-object-proxy 1.3.1
logilab-common 1.4.2
lxml 4.3.2
MarkupSafe 1.1.0
matplotlib 3.4.2
mccabe 0.6.1
microdotphat 0.2.1
mongo-db 0.1
more-itertools 8.8.0
mote 0.0.4
motephat 0.0.3
mypy 0.670
mypy-extensions 0.4.1
networkx 2.5.1
nightly 0.0.1
nudatus 0.0.4
numpy 1.20.3
oauthlib 2.1.0
olefile 0.46
packaging 20.9
pandas 1.2.4
pantilthat 0.0.7
parso 0.3.1
pexpect 4.6.0
pgzero 1.2
phatbeat 0.1.1
pianohat 0.1.0
picamera 1.13
pickleshare 0.7.5
piglow 1.2.5
pigpio 1.78
Pillow 8.2.0
pip 18.1
pluggy 0.13.1
prompt-toolkit 3.0.18
protobuf 3.17.2
psutil 5.5.1
py 1.10.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycairo 1.16.2
pycodestyle 2.7.0
pycrypto 2.6.1
pycups 1.9.73
pyflakes 2.3.1
pyftdi 0.53.1
pygame 1.9.4.post1
Pygments 2.3.1
PyGObject 3.30.4
pyinotify 0.9.6
PyJWT 1.7.0
pylint 2.2.2
pymongo 3.4.0
pyOpenSSL 19.0.0
pyparsing 2.4.7
pyserial 3.4
pysmbc 1.0.15.6
pytest 6.2.4
python-apt 1.8.4.3
python-dateutil 2.8.1
python-espeak 0.5
python-Levenshtein 0.12.2
pytz 2021.1
pyusb 1.1.1
PyWavelets 1.1.1
pyxdg 0.25
PyYAML 5.4.1
pyzmq 17.1.2
qtconsole 4.3.1
rainbowhat 0.1.0
reportlab 3.5.13
requests 2.21.0
requests-oauthlib 1.0.0
responses 0.9.0
roman 2.0.0
rpi-ws281x 4.2.6
RPi.GPIO 0.7.0
rsa 4.7.2
RTIMULib 7.2.1
scikit-image 0.18.1
scipy 1.6.3
screen 1.0.1
scrollphat 0.0.7
scrollphathd 1.2.1
SecretStorage 2.3.1
semver 2.0.1
Send2Trash 1.5.0
sense-hat 2.2.0
setuptools 40.8.0
simplegeneric 0.8.1
simplejson 3.16.0
six 1.16.0
skywriter 0.0.7
sn3218 1.2.7
soupsieve 1.8
sox 1.4.1
spidev 3.4
ssh-import-id 5.7
sysv-ipc 1.1.0
thonny 3.3.6
tifffile 2021.4.8
toml 0.10.2
torch 1.0.0a0+8322165
torchvision 0.2.0
tornado 5.1.1
touchphat 0.0.1
traitlets 4.3.2
twython 3.7.0
typed-ast 1.3.1
typing 3.7.4.3
typing-extensions 3.10.0.0
uflash 1.2.4
unicornhathd 0.0.4
urllib3 1.24.1
wcwidth 0.2.5
webencodings 0.5.1
Werkzeug 0.14.1
wheel 0.32.3
wit 6.0.0
wolframalpha 5.0.0
wrapt 1.10.11
xmltodict 0.12.0
zipp 3.4.1
I might have accidentally installed the libraries some other way when I updated, but I don't think so...
I didn't install anything using apt.
I am using Thonny Python. Thanks!
cryptography lib was old. Thanks to everyone who helped!

from google.oauth2 import service_account ModuleNotFoundError: No module named 'google'

I m trying to run my django app on appengine flexible environment. I m struck on Error.
from google.oauth2 import service_account
ModuleNotFoundError: No module named 'google'
here, i m importing service_account, because i m using google cloud storage. So in settings.py i have to write the code below
from google.oauth2 import service_account
GS_CREDENTIALS = service_account.Credentials.from_service_account_file(
os.path.join(BASE_DIR,'My Project..............001.json')
)
It is running fine on local virtual environment but not appengine flex env.
Extra:- in requirements.txt
Package Version
------------------------ ---------
asgiref 3.2.10
astroid 2.4.2
cachetools 4.1.1
certifi 2020.6.20
chardet 3.0.4
colorama 0.4.3
Django 3.0.2
django-storages 1.9.1
google-api-core 1.21.0
google-auth 1.18.0
google-cloud-core 1.3.0
google-cloud-storage 1.29.0
google-resumable-media 0.5.1
googleapis-common-protos 1.52.0
gunicorn 20.0.4
idna 2.10
isort 4.3.21
lazy-object-proxy 1.4.3
mccabe 0.6.1
Pillow 7.2.0
pip 19.0.3
protobuf 3.12.2
psycopg2 2.8.5
psycopg2-binary 2.8.5
pyasn1 0.4.8
pyasn1-modules 0.2.8
pylint 2.5.3
pytz 2020.1
requests 2.24.0
rsa 4.6
setuptools 40.8.0
six 1.15.0
sqlparse 0.3.1
toml 0.10.1
typed-ast 1.4.1
urllib3 1.25.9
wheel 0.34.2
wrapt 1.12.1
Thanks.

Cassandra doesn't complete connection with EventletConnection

In an otherwise stable environment, when I call cluster.connect(), the code just hangs indefinitely, no errors or timeout messages. The connection is contained inside a Nameko service. I suspect it is related to the Nameko service code, particularly the monkey patching involved, since the otherwise identical code works fine outside of a Nameko service.
I should note this only seems to be a problem with Python 3.7 and Cassandra 3.18. With Python 3.6 and Cassandra 3.16, this works fine.
Here is a code snippet:
import logging
from cassandra import ConsistencyLevel, cluster
from nameko.extensions import DependencyProvider
from pipeline import config
class CassandraConnection(DependencyProvider):
"""
Encapsulate a cassandra session with an open connection.
"""
def __init__(self):
self._logger = logging.getLogger('cassandra_writer')
self._cluster = None
self._session = None
def setup(self):
self._cluster = cluster.Cluster(config.get('cassandra', 'node').split(','))
self._session = self._cluster.connect()
self._session.set_keyspace(config.get('cassandra', 'keyspace_ts'))
self._session.default_consistency_level = ConsistencyLevel.QUORUM
def get_dependency(self, worker_ctx):
return self._session
Here is the complete startup log:
INFO starting services: cassandra_writer
DEBUG starting <ServiceContainer [cassandra_writer] at 0x7fa5d1411b70>
DEBUG starting <ExchangeEventHandler [cassandra_writer.write_objects] at 0x7fa5bc685ba8>
DEBUG registering provider <ExchangeEventHandler [cassandra_writer.write_objects] at 0x7fa5bc685ba8> for <QueueConsumer at 0x7fa5bc685c18>
DEBUG Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit#USRMQQA03.alphanetcapital.com', 'copyright': 'Copyright (C) 2007-2019 Pivotal Software, Inc.', 'information': 'Licensed under the MPL. See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP 21.2.6', 'product': 'RabbitMQ', 'version': '3.7.13'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']
WARNING Cluster.__init__ called with contact_points specified, but no load_balancing_policy. In the next major version, this will raise an error; please specify a load-balancing policy. (contact_points = ['uscstardev01', 'uscstardev02', 'uscstardev03'], lbp = None)
INFO <class 'cassandra.io.eventletreactor.EventletConnection'>
DEBUG Connecting to cluster, contact points: ['uscstardev01', 'uscstardev02', 'uscstardev03']; protocol version: 4
DEBUG Host 172.16.9.29:9042 is now marked up
DEBUG Host 172.16.9.30:9042 is now marked up
DEBUG Host 172.16.9.31:9042 is now marked up
DEBUG [control connection] Opening new connection to 172.16.9.31:9042
DEBUG Sending initial options message for new connection (140349806704400) to 172.16.9.31:9042
DEBUG Received options response on new connection (140349806704400) from 172.16.9.31:9042
DEBUG Sending StartupMessage on <EventletConnection(140349806704400) 172.16.9.31:9042>
DEBUG Sent StartupMessage on <EventletConnection(140349806704400) 172.16.9.31:9042>
DEBUG Got ReadyMessage on new connection (140349806704400) from 172.16.9.31:9042
DEBUG [control connection] Established new connection <EventletConnection(140349806704400) 172.16.9.31:9042>, registering watchers and refreshing schema and topology
DEBUG [control connection] Refreshing node list and token map using preloaded results
INFO Using datacenter 'devus01' for DCAwareRoundRobinPolicy (via host '172.16.9.31:9042'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes
DEBUG [control connection] Finished fetching ring info
DEBUG [control connection] Rebuilding token map due to topology changes
DEBUG Control connection created
DEBUG Initializing connection for host 172.16.9.29:9042
DEBUG Sending initial options message for new connection (140349806806968) to 172.16.9.29:9042
DEBUG Initializing connection for host 172.16.9.30:9042
DEBUG Sending initial options message for new connection (140349805903544) to 172.16.9.30:9042
DEBUG Received options response on new connection (140349806806968) from 172.16.9.29:9042
DEBUG Sending StartupMessage on <EventletConnection(140349806806968) 172.16.9.29:9042>
DEBUG Sent StartupMessage on <EventletConnection(140349806806968) 172.16.9.29:9042>
DEBUG Received options response on new connection (140349805903544) from 172.16.9.30:9042
DEBUG Sending StartupMessage on <EventletConnection(140349805903544) 172.16.9.30:9042>
DEBUG Sent StartupMessage on <EventletConnection(140349805903544) 172.16.9.30:9042>
DEBUG Got ReadyMessage on new connection (140349806806968) from 172.16.9.29:9042
DEBUG Finished initializing connection for host 172.16.9.29:9042
DEBUG Added pool for host 172.16.9.29:9042 to session
DEBUG Initializing connection for host 172.16.9.31:9042
DEBUG Got ReadyMessage on new connection (140349805903544) from 172.16.9.30:9042
DEBUG Finished initializing connection for host 172.16.9.30:9042
DEBUG Added pool for host 172.16.9.30:9042 to session
The last message is that last one that appears before the process simply hangs.
Here is my environment:
adyne_services_common 0.1 py37_0
alphasuite 1.79a1 py37_0
amqp 2.3.2 py_1
appdirs 1.4.3 py37h28b3542_0
arrow 0.12.1 py37_1
asn1crypto 0.24.0 py37_0
attrs 18.2.0 py37h28b3542_0
backcall 0.1.0 py37_0
backports 1 py37_1
backports.os 0.1.1 py37_0
bcrypt 3.1.5 py37h7b6447c_0
beautifulsoup4 4.6.3 py37_0
billiard 3.6.0.0 py37h516909a_0
blas 1 mkl
blpapi 3.12.2 py37_blpapicpp3.12.2.1_1
ca-certificates 2018.03.07 0
cached-property 1.5.1 py37_0
cachetools 3.0.0 py_0
cassandra-driver 3.18.0 py37_0
celery 4.3.0 py_1
certifi 2018.11.29 py37_0
cffi 1.11.5 py37he75722e_1
chardet 3.0.4 py37_1
conda 4.5.12 py37_0
conda-env 2.6.0 1
cryptography 2.4.2 py37h1ba5d50_0
cycler 0.10.0 py37_0
cython 0.28.5 py37hf484d3e_0
dbus 1.13.2 h714fa37_1
decorator 4.3.0 py37_0
defusedxml 0.5.0 py37_1
distro 1.4.0 py_0
elasticsearch 5.4.0 py37_0
et_xmlfile 1.0.1 py37_0
eventlet 0.23.0 py37_1000
expat 2.2.6 he6710b0_0
fontconfig 2.13.0 h9420a91_0
freetype 2.9.1 h8a8886c_1
glib 2.56.2 hd408876_0
greenlet 0.4.15 py37h7b6447c_0
gst-plugins-base 1.14.0 hbbd80ab_1
gstreamer 1.14.0 hb453b48_1
icu 58.2 h211956c_0
idna 2.8 py37_0
importlib_metadata 0.6 py37_0
intel-openmp 2019.1 144
ipython 7.2.0 py37h39e3cac_0
ipython_genutils 0.2.0 py37_0
isodate 0.6.0 py37_0
jdcal 1.4 py37_0
jedi 0.13.2 py37_0
jinja2 2.1 py37_0
jpeg 9b habf39ab_1
jsonschema 2.6.0 py37_0
kiwisolver 1.0.1 py37hf484d3e_0
kombu 4.6.1 py_0
krb5 1.16.1 h173b8e3_7
libedit 3.1.20170329 h6b74fdf_2
libffi 3.2.1 h4deb6c0_3
libgcc-ng 8.2.0 hdf63c60_1
libgfortran-ng 7.3.0 hdf63c60_0
libpng 1.6.35 hbc83047_0
libsodium 1.0.16 h1bed415_0
libstdcxx-ng 8.2.0 hdf63c60_1
libuuid 1.0.3 h1bed415_2
libxcb 1.13 h1bed415_1
libxml2 2.9.8 h26e45fe_1
libxslt 1.1.32 h1312cb7_0
lxml 4.2.5 py37hefd8a0e_0
lz4 2.1.6 py37h7b6447c_0
lz4-c 1.8.1.2 h14c3975_0
markupsafe 1.1.0 py37h7b6447c_0
matplotlib 3.0.2 py37h5429711_0
mkl 2019.1 144
mkl_fft 1.0.6 py37hd81dba3_0
mkl_random 1.0.2 py37hd81dba3_0
mock 2.0.0 py37_0
mysqlclient 1.3.14 ubuntu1404
nameko 2.11.0 py37_3
ncurses 6.1 he6710b0_1
numpy 1.15.4 py37h7e9f1db_0
numpy-base 1.15.4 py37hde5b4d6_0
openjdk 8.0.121 1
openpyxl 2.5.12 py37_0
openssl 1.1.1 h7b6447c_0
pandas 0.23.4 py37h04863e7_0
paramiko 2.4.2 py37_0
parso 0.3.1 py37_0
path.py 11.5.0 py37_0
patsy 0.5.1 py37_0
pbr 5.1.1 py37_0
pcre 8.42 h439df22_0
pexpect 4.6.0 py37_0
pickleshare 0.7.5 py37_0
pika 0.12.0 py_1
pip 18.1 py37_0
pipeline 0.68a1 py37_1
prompt_toolkit 2.0.7 py37_0
ptyprocess 0.6.0 py37_0
pyasn1 0.4.5 py_0
pycosat 0.6.3 py37h14c3975_0
pycparser 2.19 py37_0
pygments 2.3.1 py37_0
pykerberos 1.2.1 py37h14c3975_0
pynacl 1.2.1 py37h14c3975_0
pyodbc 4.0.25 py37he6710b0_0
pyopenssl 18.0.0 py37_0
pyparsing 2.3.0 py37_0
pyqt 5.9.2 py37h05f1152_2
pysocks 1.6.8 py37_0
python 3.7.1 h0371630_7
python-dateutil 2.7.5 py37_0
pytz 2018.7 py37_0
pyvolar 3.10.8 py37_1
pyyaml 3.13 py37h14c3975_0
qt 5.9.7 h5867ecd_1
readline 7 h7b6447c_5
redis-py 3.2.0 py_0
requests 2.21.0 py37_0
requests-kerberos 0.12.0 py37_0
requests-toolbelt 0.8.0 py37_0
ruamel_yaml 0.15.46 py37h14c3975_0
scipy 1.1.0 py37h7c811a0_2
seaborn 0.9.0 py37_0
setuptools 40.6.3 py37_0
simplejson 3.16.0 py37h14c3975_0
sip 4.19.8 py37hf484d3e_0
six 1.12.0 py37_0
sqlalchemy 1.2.15 py37h7b6447c_0
sqlite 3.26.0 h7b6447c_0
statsmodels 0.9.0 py37h035aef0_0
tabula-py 1.1.1 py37_1000
tk 8.6.8 hbc83047_0
tornado 5.1.1 py37h7b6447c_0
traitlets 4.3.2 py37_0
ujson 1.35 py37h14c3975_0
unixodbc 2.3.7 h14c3975_0
urllib3 1.24.1 py37_0
vine 1.3.0 py_0
wcwidth 0.1.7 py37_0
werkzeug 0.14.1 py37_0
wheel 0.32.3 py37_0
wrapt 1.10.11 py37h14c3975_2
xlrd 1.2.0 py37_0
xlwt 1.3.0 py37_0
xz 5.2.4 h14c3975_4
yaml 0.1.7 h96e3832_1
zeep 3.2.0 py_1000
zlib 1.2.11 h7b6447c_3
This is an issue we fixed in the last cassandra-driver release (3.19.0). However, you will need to install the "futurist" package to get eventlet working with Python 3.7. For more details, see https://github.com/eventlet/eventlet/issues/508

Trying to access google spreadsheet but No module named 'google'

Trying to read data from one of my google spreadsheet.
I've got the JSON file from google, trying to put it as a string in the script.
this is what I have so far:
import json
import os
from google.oauth2 import service_account
from google.cloud import translate
.
.
.
json_as_string = """........"""
info = json.loads(os.environ[json_as_string])
creds = service_account.Credentials.from_service_account_info(info)
# Instantiates a client
translate_client = translate.Client(credentials=creds)
# credentials = ServiceAccountCredentials.from_json_keyfile_name("SendMyCardCheckUP-2e671ca3c2eb.json", scope)
client = gspread.authorize(credentials)
sheet = client.open("file_name").sheet1
this is what I get back :
from google.oauth2 import service_account
ModuleNotFoundError: No module named 'google'
Already tried through cmd -
pip install -t lib google-auth google-auth-httplib2 google-api-python-client --upgrade
pip install --upgrade google-api-python-client
For some reason, the import of the "google" package doesn't work, any ideas?
EDIT:
pip list:
Package Version
------------------------ ----------
altgraph 0.16.1
asn1crypto 0.24.0
attrs 19.1.0
beautifulsoup4 4.8.0
cachetools 3.1.0
certifi 2018.11.29
cffi 1.12.3
chardet 3.0.4
cryptography 2.6.1
cycler 0.10.0
decorator 4.4.0
future 0.17.1
google 2.0.2
google-api-core 1.14.2
google-api-python-client 1.7.11
google-auth 1.6.3
google-auth-httplib2 0.0.3
google-auth-oauthlib 0.4.0
google-cloud 0.34.0
google-cloud-core 1.0.3
google-cloud-storage 1.18.0
google-cloud-translate 1.6.0
google-oauth 1.0.1
google-resumable-media 0.3.2
googleapis-common-protos 1.6.0
grpcio 1.23.0
gspread 3.1.0
httplib2 0.12.3
idna 2.8
ipython-genutils 0.2.0
jsonschema 3.0.1
jupyter-core 4.4.0
kiwisolver 1.1.0
macholib 1.11
matplotlib 3.0.3
nbformat 4.4.0
numpy 1.16.3
oauth2client 4.1.3
oauthlib 3.0.1
opencv-python 4.1.0.25
pefile 2018.8.8
pip 19.2.2
plotly 3.8.1
protobuf 3.8.0rc1
py 1.8.0
pyasn1 0.4.5
pyasn1-modules 0.2.5
pycparser 2.19
pygame 1.9.6
PyInstaller 3.4
pyOpenSSL 19.0.0
pyparsing 2.4.0
pyrsistent 0.15.1
python-dateutil 2.8.0
python-pygaze 0.6.0a25
pytz 2019.1
pywin32-ctypes 0.2.0
requests 2.22.0
requests-oauthlib 1.2.0
retrying 1.3.3
rsa 4.0
selenium 3.141.0
setuptools 39.0.1
six 1.12.0
soupsieve 1.9.2
traitlets 4.3.2
uritemplate 3.0.0
urllib3 1.24.1
FOUND IT -
pip install google_oauth2_tool
will make the service account work.
pip install google-cloud-storage
will make from google.cloud work
pip install google.cloud.translate

Categories