i want to use pillow module but - heroku

2020-08-05T11:18:47.632502+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 653, in load_extension
2020-08-05T11:18:47.632862+00:00 app[worker.1]: self._load_from_module_spec(spec, name)
2020-08-05T11:18:47.632903+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 599, in _load_from_module_spec
2020-08-05T11:18:47.633218+00:00 app[worker.1]: raise errors.ExtensionFailed(key, e) from e
2020-08-05T11:18:47.633309+00:00 app[worker.1]: discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.DPB' raised an error: ModuleNotFoundError: No module named 'Pillow'
2020-08-05T11:18:47.713878+00:00 heroku[worker.1]: Process exited with status 1
in pip list it shows
image v1.5.32
Pillow v7.2.0
what is the issue?
code:
from Pillow import Image

Related

Mlflow model in Heroku

I built an MLflow model and call a prediction on a streamlit dashboard, in it work fine in local.
In Heroku, the app which works fine locally failed to send the request online, what am I missing to such deployment?
Below the error code raised.
Procfile :
web: mlflow sagemaker deploy -m mlflow_model/
web: sh setup.sh && streamlit run app.py
Heroku logs:
2022-01-07T10:14:15.759252+00:00 app[web.1]: Traceback (most recent call last):
2022-01-07T10:14:15.759252+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/streamlit/script_runner.py", line 354, in _run_script
2022-01-07T10:14:15.759252+00:00 app[web.1]: exec(code, module.__dict__)
2022-01-07T10:14:15.759252+00:00 app[web.1]: File "/app/app.py", line 204, in <module>
2022-01-07T10:14:15.759252+00:00 app[web.1]: main()
2022-01-07T10:14:15.759252+00:00 app[web.1]: File "/app/app.py", line 119, in main
2022-01-07T10:14:15.759253+00:00 app[web.1]: pred = request_prediction(MLFLOW_URI, ml_data)[0]
2022-01-07T10:14:15.759253+00:00 app[web.1]: File "/app/app.py", line 63, in request_prediction
2022-01-07T10:14:15.759253+00:00 app[web.1]: response = requests.request(
2022-01-07T10:14:15.759253+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/requests/api.py", line 61, in request
2022-01-07T10:14:15.759253+00:00 app[web.1]: return session.request(method=method, url=url, **kwargs)
2022-01-07T10:14:15.759254+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
2022-01-07T10:14:15.759254+00:00 app[web.1]: resp = self.send(prep, **send_kwargs)
2022-01-07T10:14:15.759254+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
2022-01-07T10:14:15.759254+00:00 app[web.1]: r = adapter.send(request, **kwargs)
2022-01-07T10:14:15.759254+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
2022-01-07T10:14:15.759254+00:00 app[web.1]: raise ConnectionError(e, request=request)
2022-01-07T10:14:15.759259+00:00 app[web.1]: requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /invocations (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f2452d23790>: Failed to establish a new connection: [Errno 111] Connection refused'))
We have in place some guidelines to ensure we can help each other more easily:
do not upload screenshots of code or error logs, but copy-paste and format them
add some code and/or configuration which can help understand the context (i.e. Procfile, application startup code). It is great if you can include a Github repository (if your code is public of course) and ALWAYS avoid including passwords and tokens.
Back to your problem: can you post the Heroku logs and the code to run the streamlit app?

Heroku: Problem with deploying cherrypy app

I'm basically trying to deploy the example in the CherryPy tutorial to Heroku (https://docs.cherrypy.org/en/latest/tutorials.html#tutorial-8-make-it-smoother-with-ajax). When I run the code locally, everything works fine. After deployment to Heroku, I get several error messages:
2020-04-16T17:42:19.422074+00:00 app[web.1]: Traceback (most recent call last):
2020-04-16T17:42:19.422076+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 670, in respond
2020-04-16T17:42:19.422076+00:00 app[web.1]: response.body = self.handler()
2020-04-16T17:42:19.422076+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 217, in __call__
2020-04-16T17:42:19.422077+00:00 app[web.1]: self.body = self.oldhandler(*args, **kwargs)
2020-04-16T17:42:19.422077+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cherrypy/_cpdispatch.py", line 61, in __call__
2020-04-16T17:42:19.422078+00:00 app[web.1]: return self.callable(*self.args, **self.kwargs)
2020-04-16T17:42:19.422078+00:00 app[web.1]: File "app.py", line 19, in GET
2020-04-16T17:42:19.422078+00:00 app[web.1]: return cherrypy.session['mystring']
2020-04-16T17:42:19.422079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cherrypy/__init__.py", line 246, in __getitem__
2020-04-16T17:42:19.422079+00:00 app[web.1]: return child[key]
2020-04-16T17:42:19.422079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cherrypy/lib/sessions.py", line 309, in __getitem__
2020-04-16T17:42:19.422080+00:00 app[web.1]: return self._data[key]
2020-04-16T17:42:19.422080+00:00 app[web.1]: KeyError: 'mystring'
2020-04-17T09:24:31.597650+00:00 app[web.1]: File "app.py", line 45, in <module>
2020-04-17T09:24:31.597765+00:00 app[web.1]: webapp.generator = StringGeneratorWebService()
2020-04-17T09:24:31.597768+00:00 app[web.1]: TypeError: expose_() missing 1 required positional argument: 'func'
2020-04-17T09:24:32.000000+00:00 app[api]: Build succeeded
My Procfile simply contains
web: python app.py
My guess is that the problem has something to do with the little css-trick that avoids refreshing the page in order display the result of a request. But, as you can see, I'm totally new to deployment and this is also my first question on stackoverflow--so my apologies in advance in case I'm missing something obvious here. Any help is much appreciated!

kubernetes python3.5 SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

I followed the examples:
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
But always got this error:
2018-08-28 23:03:48,818 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /api/v1/pods?watch=False
...ommit some retry logs
Traceback (most recent call last):
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 444, in wrap_socket
cnx.do_handshake()
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1907, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/OpenSSL/SSL.py", line 1639, in _raise_ssl_error
_raise_current_error()
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/util/ssl_.py", line 372, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 450, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/apis/core_v1_api.py", line 13608, in list_pod_for_all_namespaces
(data) = self.list_pod_for_all_namespaces_with_http_info(**kwargs)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/apis/core_v1_api.py", line 13705, in list_pod_for_all_namespaces_with_http_info
collection_formats=collection_formats)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/api_client.py", line 321, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/api_client.py", line 155, in __call_api
_request_timeout=_request_timeout)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/api_client.py", line 342, in request
headers=headers)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/rest.py", line 231, in GET
query_params=query_params)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/kubernetes/client/rest.py", line 205, in request
headers=headers)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/request.py", line 68, in request
**urlopen_kw)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/request.py", line 89, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/poolmanager.py", line 322, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/maxpeng/.pyenv/versions/3.5.0/lib/python3.5/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xx.xx.xx.xx', port=xxxx): Max retries exceeded with url: /api/v1/pods?watch=False (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
Mac OSX 10.13.6
kubectl version
Client Version: version.Info{Major:"1", Minor:"11",
GitVersion:"v1.11.2",
GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239",
GitTreeState:"clean", BuildDate:"2018-08-08T16:31:10Z",
GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10",
GitVersion:"v1.10.4",
GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d",
GitTreeState:"clean", BuildDate:"2018-06-06T08:00:59Z",
GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
pip list
|Package | Version|
|certifi | 2018.8.24|
|kubernetes | 7.0.0|
......ommit other dependencies
P.S. I tried the solution here: http://www.cdotson.com/2017/01/sslerror-with-python-3-6-x-on-macos-sierra/. But without luck.
This appears to be an issue with the client script not being able to find/accept/verify the cert. Setting the location of the cert is likely the most viable method of resolution directly from the script:
from kubernetes import client
from kubernetes.client import Configuration, ApiClient
config = Configuration()
config.api_key = {'authorization': 'Bearer <api_key>'}
config.host = 'https://my-kubernetes-cluster'
config.ssl_ca_cert = "/path/to/ca_chain.crt"
api_client = ApiClient(configuration=config)
v1 = client.CoreV1Api(api_client)
v1.list_pod_for_all_namespaces(watch=False)
You could also set this up directly in .kube/config:
apiVersion: v1
clusters:
- cluster:
api-version: v1
certificate-authority: /path/to/ca_chain.crt
server: "https://my-kubernetes-cluster"
...
The last option is to skip verification ( not recommend because it defeats the purpose of SSL ):
v1 = client.CoreV1Api()
v1.api_client.configuration.verify_ssl = False
More Information:
• https://github.com/kubernetes-client/python/issues/521
• How to specify a CA bundle in kubernetes python client

Spark unzip from S3

I'm using Spark (pyspark) to read in data and have ran into a snag as some of my data is now in .gz format.
%pyspark
data = sc.textFile("s3://mybucket.file.gz")
data.first()
Traceback (most recent call last):
File "/tmp/zeppelin_pyspark-5205743886772607083.py", line 267, in <module>
raise Exception(traceback.format_exc())
Exception: Traceback (most recent call last):
File "/tmp/zeppelin_pyspark-5205743886772607083.py", line 260, in <module>
exec(code)
File "<stdin>", line 1, in <module>
File "/usr/lib/spark/python/pyspark/rdd.py", line 1041, in count
return self.mapPartitions(lambda i: [sum(1 for _ in i)]).sum()
File "/usr/lib/spark/python/pyspark/rdd.py", line 1032, in sum
return self.mapPartitions(lambda x: [sum(x)]).fold(0, operator.add)
File "/usr/lib/spark/python/pyspark/rdd.py", line 906, in fold
vals = self.mapPartitions(func).collect()
File "/usr/lib/spark/python/pyspark/rdd.py", line 809, in collect
port = self.ctx._jvm.PythonRDD.collectAndServe(self._jrdd.rdd())
File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py", line 1133, in __call__
answer, self.gateway_client, self.target_id, self.name)
File "/usr/lib/spark/python/pyspark/sql/utils.py", line 63, in deco
return f(*a, **kw)
File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py", line 319, in get_return_value
format(target_id, ".", name), value)
Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 31.0 failed 4 times, most recent failure: Lost task 0.3 in stage 31.0 (TID 270, ip-172-16-238-231.us-west-1.compute.internal, executor 17): java.io.IOException: incorrect header check
at org.apache.hadoop.io.compress.zlib.ZlibDecompressor.inflateBytesDirect(Native Method)
Any thoughts on how to read this in and uncompress?
Strangely enough, all I had to do is remove the "gz" off the end and it worked.

Don't build docs from local hosted readthedocs

I am deploy local instance application readthedocs. When I'm start the generation of documentation appear errors.
Here logs:
29/May/2015 08:47:00] INFO [requests.packages.urllib3.connectionpool:180] Starting new HTTP connection (1): localhost
[29/May/2015 08:47:00] INFO [projects.tasks:87] (Build) [diclonius-doc:] Building
[29/May/2015 08:47:00] ERROR [projects.tasks:576] Unable to post a new build
Traceback (most recent call last):
File "/srv/readthedoc/readthedocs/projects/tasks.py", line 574, in record_build
api.build(build['id']).put(build)
File "/srv/readthedoc/.env/local/lib/python2.7/site-packages/slumber/__init__.py", line 164, in put
resp = self._request("PUT", data=data, files=files, params=kwargs)
File "/srv/readthedoc/.env/local/lib/python2.7/site-packages/slumber/__init__.py", line 108, in _request
raise exceptions.HttpClientError("Client Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content)
HttpClientError: Client Error 401: http://localhost:8000/api/v1/build/7/
[29/May/2015 08:47:00] INFO [projects.tasks:209] (Build) [diclonius-doc:latest] Updating docs from VCS
...
...
[29/May/2015 08:47:01] INFO [vcs_support.base:66] VCS[diclonius-doc:latest]: 47973225b291c752663da75d5ba218e5423029c4
[29/May/2015 08:47:01] ERROR [projects.tasks:576] Unable to post a new build
Traceback (most recent call last):
File "/srv/readthedoc/readthedocs/projects/tasks.py", line 574, in record_build
api.build(build['id']).put(build)
File "/srv/readthedoc/.env/local/lib/python2.7/site-packages/slumber/__init__.py", line 164, in put
resp = self._request("PUT", data=data, files=files, params=kwargs)
File "/srv/readthedoc/.env/local/lib/python2.7/site-packages/slumber/__init__.py", line 108, in _request
raise exceptions.HttpClientError("Client Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content)
HttpClientError: Client Error 401: http://localhost:8000/api/v1/build/7/
[29/May/2015 08:47:01] INFO [projects.tasks:308] (Build) [diclonius-doc:latest] Removing existing build dir
[29/May/2015 08:47:01] INFO [projects.utils:81] Running: 'virtualenv-2.7 -p python --no-site-packages /srv/readthedoc/user_builds/diclonius-doc/envs/latest' [/srv/readthedoc]
[29/May/2015 08:47:02] INFO [projects.utils:81] Running: '/srv/readthedoc/user_builds/diclonius-doc/envs/latest/bin/pip install --use-wheel --find-links=/srv/readthedoc/deploy/wheels -U sphinx==1.3.1 Pygments==2.0.2 virtualenv==1.10.1 setuptools==1.1 docutils==0.11 mkdocs==0.11.1 mock==1.0.1 pillow==2.6.1 readthedocs-sphinx-ext==0.4.4 sphinx-rtd-theme==0.1.8 recommonmark==0.1.1' [/srv/readthedoc]
I am use server gunicorn and nginx for proxy.

Resources