In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The main content of this article is to explain "Python can not read pickle files run in cloud applications TypeError: _ _ cinit__ () how to handle", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "Python can't read pickle files and run TypeError: _ _ cinit__ () in cloud applications."
There was one I deployed to the GCP cloud to run a fast API application, and it worked well until yesterday, and I really don't know what went wrong. When I read the .pkl file, the problem seems to start on this line.
Model = pickle.load (open (os.path.join ('models',' appartementen.pkl'), 'rb'))
Retroactive:
File "pandas/_libs/internals.pyx", line 572 In pandas._libs.internals.BlockManager.__cinit__: TypeError: _ _ cinit__ () takes at least 2 positional arguments (0 given) at (/ app/src/api/util.py:25) at (/ app/src/api/main.py:8) at _ call_with_frames_removed at exec_module (: 728) at _ load_unlocked (: 677) at _ find_and_load_unlocked (: 967) at _ find_and_load At _ gcd_import (: 1006) at import_module (/ usr/local/lib/python3.7/importlib/__init__.py:127) at import_app (/ usr/local/lib/python3.7/site-packages/gunicorn/util.py:358) at load_wsgiapp (/ usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:39) at load (/ usr/local/lib/python3.7/site-packages/gunicorn/app) / wsgiapp.py:49) at wsgi (/ usr/local/lib/python3.7/site-packages/gunicorn/app/base.py:67) at load_wsgi (/ usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py:144) at init_process (/ usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py:119) at spawn_worker (/ usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py:583)
Note that everything went well when I deployed this application locally.
My Doc file:
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7WORKDIR / appCOPY. . / COPY src. / src/COPY models. / models/RUN pip install-r requirements.txtCOPY setup.py. / CMD exec gunicorn src.api.main:app
How to deploy to the cloud to run:
Gcloud builds submit-tag gcr.io/project-id/api-timeout=3600gcloud run deploy api-image gcr.io/project-id/api-platform managed-project=project-id-region=europe-west4
Requirements.txt:
Fastapi==0.63.0google-cloud-bigquery [bqstorage,pandas] = = 1.24.0sentry_sdk==1.0.0xgboost==1.3.3scikit-learn==0.23.1shap==0.39.0matplotlib==3.4.1
I tried to use the same version according to this suggestion, but the problem still exists. Scikit-learn
Solution:
It may be that there is an incompatibility between the object version and the container version, but restoring that version is useful to me. So: pandaspandaspandas1.2.51.3.0
Pip uninstall pandaspip install pandas==1.2.5 at this point, I believe that "Python can not read pickle files run in the cloud application TypeError: _ _ cinit__ () how to deal with", might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.