I am running my fastapi via Docker, here is the main.py
import sys
from fastapi import FastAPI
from src.redactor import DSARRedaction
app = FastAPI()
#app.get("/")
async def run_redaction():
DSARRedaction("kulveer").run_redaction()
return {"message": "Redaction Completed"}
and here is the Dockerfile
FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt .
RUN apt-get update
RUN apt-get install -y python3-opencv
# Install dependencies for textract
RUN apt-get install -y ghostscript python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig \
libpulse-dev zlib1g-dev qpdf
RUN apt -y install tesseract-ocr
RUN apt -y install libtesseract-dev
RUN pip install --upgrade pip && pip install -r requirements.txt
COPY . .
RUN python3 -m spacy download en_core_web_lg
EXPOSE 50
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "50"]
I am trying to run the following python script as I just want to be able to get the URL via python without having to click on it.
import requests
requests.get('http://0.0.0.0:50/')
But every time I try to run that code to request the API, I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.8/http/client.py", line 1256, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1302, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1251, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1011, in _send_output
self.send(msg)
File "/usr/local/lib/python3.8/http/client.py", line 951, in send
self.connect()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f34d008fca0>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=50): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f34d008fca0>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "x.py", line 3, in <module>
requests.Session().get('http://0.0.0.0:50')
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=50): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f34d008fca0>: Failed to establish a new connection: [Errno 111] Connection refused'))
Any ideas on why this is happening?
Access your endpoint at http://localhost:50 instead of http://0.0.0.0:50 so it should be
import requests
requests.get('http://localhost:50/')
Related
I am attempting to scrape text off of websites, and I am using the requests module to do so.
With the code
response = requests.get('https://kjt.hebei.gov.cn/www/index_ssl/index.html', verify=False)
I receive back the following error:
Traceback (most recent call last):
File "E:\new_work\venv.spider\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "E:\new_work\venv.spider\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "E:\new_work\venv.spider\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "E:\new_work\venv.spider\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "E:\new_work\venv.spider\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "E:\new_work\venv.spider\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python39\lib\ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "C:\Python39\lib\ssl.py", line 1041, in _create
self.do_handshake()
File "C:\Python39\lib\ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: BAD_ECPOINT] bad ecpoint (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\new_work\venv.spider\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "E:\new_work\venv.spider\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "E:\new_work\venv.spider\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kjt.hebei.gov.cn', port=443): Max retries exceeded with url: /www/index_ssl/index.html (Caused by SSLError(SSLError(1, '[SSL: BAD_ECPOINT] bad ecpoint (_ssl.c:1129)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\new_work\innocom\innocom\scripts\__init__.py", line 44, in <module>
response = requests.get('https://kjt.hebei.gov.cn/www/index_ssl/index.html', verify=False)
File "E:\new_work\venv.spider\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "E:\new_work\venv.spider\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "E:\new_work\venv.spider\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "E:\new_work\venv.spider\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "E:\new_work\venv.spider\lib\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='kjt.hebei.gov.cn', port=443): Max retries exceeded with url: /www/index_ssl/index.html (Caused by SSLError(SSLError(1, '[SSL: BAD_ECPOINT] bad ecpoint (_ssl.c:1129)')))
There was no more i can find about bad ecpoint, I had installed some packages:
anyio 3.6.2
certifi 2020.12.5
cffi 1.15.1
charset-normalizer 2.0.12
cryptography 38.0.3
h11 0.12.0
httpcore 0.15.0
httpx 0.23.0
idna 3.4
pip 22.0.4
pycparser 2.21
pyOpenSSL 22.1.0
requests 2.28.1
rfc3986 1.5.0
setuptools 58.1.0
six 1.16.0
sniffio 1.3.0
urllib3 1.26.12
I changed the version of pyOpenSSL, urllib3, certifi to others, but it did not work.
By the way, I ues python3.9 in windows 10. However, with the same code, it work with python3.6.
And with python3.9, requests.get work for other https url. It just not work for https://kjt.hebei.gov.cn/www/index_ssl/index.html.
Any help would be greatly appreciated! Thank you!
i'm trying to install pygame package on my computer which one is not connected to internet.
(env : windows10, python 3.9(anaconda))
so i downloaded a "pygame-2.1.2.tar" file from www.pypi.org and then tried to install it
from cmd with "python setup.py install" commend.
then it shows error message like below
===============================================================================
(base) C:\pythonpackage\pygame-2.1.2>python setup.py install
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip
d561079ec622b0bab5a9e02976f5d540b0622da
---
For help with compilation see:
https://www.pygame.org/wiki/CompileWindows
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 174, in
_new_conn
conn = connection.create_connection(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 73,
in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\ProgramData\Anaconda3\lib\socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699,
in urlopen
httplib_response = self._make_request(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382,
in _make_request
self._validate_conn(conn)
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010,
in _validate_conn
conn.connect()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 358, in
connect
conn = self._new_conn()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 186, in
_new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at
0x00000237AF075250>: Failed to establish a new connection: [Errno 11002] getaddrinfo
failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in
send
resp = conn.urlopen(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755,
in urlopen
retries = retries.increment(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 574, in
increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.libsdl.org', port=443):
Max retries exceeded with url: /release/SDL2-devel-2.0.18-VC.zip (Caused by
NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000237AF075250>:
Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\pythonpackage\pygame-2.1.2\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 290, in
ask
update(x86=x86, x64=x64)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 273, in
update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 124, in
download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 47, in
download_sha1_unzip
response = requests.get(url)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in
request
resp = self.send(prep, **send_kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in
send
r = adapter.send(request, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 516, in
send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.libsdl.org', port=443):
Max retries exceeded with url: /release/SDL2-devel-2.0.18-VC.zip (Caused by
NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000237AF075250>:
Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
===============================================================================
please let me know how to install pygame on offline environment.
i need your help!! please~~
Solution 1 (It works for me; simple but tricky)
My first suggestion is just using .whl file. You can download pygame.whl, which is another type of installation file, from another computer and move the two files to the computer with no internect connection.
You can download the files here:
.whl file for Window & Python3.9 (for example,
pygame-2.1.2-cp39-cp39-win_amd64.whl):
https://pypi.org/project/pygame/#files
Actually, .whl is a zipfile. You can unzip the .whl file then you can see three folders: pygame, pygame-2.1.2.data, and pygame-2.1.2.dist-info. You just need pygame folder.
You can copy the folder and paste it to your python project. Then you can simply import pygame. I just tried this way and it works for me. (I even tried to run an example game)
Solution 2
Another suggestion is to download pip and pygame.whl from another computer and move the two files to the computer with no internect connection.
You can download the files here:
pip (for example, pip-22.0.3.tar.gz): https://pypi.org/project/pip/#files
.whl file for Window & Python3.9 (for example,
pygame-2.1.2-cp39-cp39-win_amd64.whl):
https://pypi.org/project/pygame/#files
After downloading and moving the two files to the computer with no internect connection, you first unzip the pip-22.0.3.tar.gz and install pip by tying following command inside of the pip folder (pip also has setup.py file):
python setup.py install
Now, pip has been installed. Then, install using the .whl file using pip in the folder that .whl file exist.
python -m pip install pygame-2.1.2-cp39-cp39-win_amd64.whl
I hope it help you emjoy pygame.
you can run command: pip install pygame
I am trying my hands on SPACY library for NLP and facing issues while installing. Following are the steps taken:
!pip3 install spacy
!python -m spacy download en_core_web_sm
I am getting following errors.
What needs to be done to fix it?
2021-03-10 14:12:10.063797: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-03-10 14:12:10.064255: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 573, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /explosion/spacy-models/master/compatibility.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\__main__.py", line 4, in <module>
setup_cli()
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\cli\_util.py", line 68, in setup_cli
command(prog_name=COMMAND)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py", line 497, in wrapper
return callback(**use_params) # type: ignore
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\cli\download.py", line 35, in download_cli
download(model, direct, sdist, *ctx.args)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\cli\download.py", line 67, in download
compatibility = get_compatibility()
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\cli\download.py", line 78, in get_compatibility
r = requests.get(about.__compatibility__)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\bj\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /explosion/spacy-models/master/compatibility.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
I also tried this option, but this is not working:
PS C:\Users\bj> pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='github-releases.githubusercontent.com', port=443): Max retries exceeded with url: /84940268/85ec3200-48aa-11e9-9878-337412e36828?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210310%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210310T163448Z&X-Amz-Expires=300&X-Amz-Signature=1f872d0cc838d305c2ab952ec0a685a22a62894f38e0bd03b6920692d9755cce&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=84940268&response-content-disposition=attachment%3B%20filename%3Den_core_web_sm-2.1.0.tar.gz&response-content-type=application%2Foctet-stream (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
Python version 3.8, Windows 10
Add https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz to your requirements.txt file.
Next, install using pip3 install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host github.com -r requirements.txt
I'm working in a Django project, and I want to use the Docker SDK for Python to create some services.
My django app is dockerized, it's a clone of this repository.
This is the Dockerfile:
FROM python:3.6.0
RUN wget http://rubies.travis-ci.org/ubuntu/14.04/x86_64/ruby-2.3.1.tar.bz2 \
&& tar xvjf ruby-2.3.1.tar.bz2 \
&& cp -rp ruby-2.3.1/* /usr/local/ \
&& rm -rf ruby-2.3.1.tar.bz2 ruby-2.3.1/
RUN mkdir /code
WORKDIR /code
RUN easy_install -U pip
RUN pip install -U pip setuptools
ADD requirements.txt /code/requirements.txt
RUN pip install -r requirements.txt
And this is the docker-compose file:
version: '2'
services:
web:
build: .
image: djangobase
command: python manage.py runserver 0.0.0.0:8000
ports:
- "3000:3000"
- "8000:8000"
volumes:
- .:/code
depends_on:
- migration
- db
db:
image: postgres:10.1
volumes:
- .:/tmp/data/
migration:
image: djangobase
command: python manage.py migrate --noinput
volumes:
- .:/code
depends_on:
- db
I have added docker==3.5.0 to the requirements file.
After to run the commands docker-compose build and docker-compose up I have the django project running perfectly.
My problems start when I try to follow the steps described here, after the installation of the docker==3.5.0 library.
import docker
client = docker.from_env()
client.containers.run("ubuntu", "echo hello world")
When I try to run the third line, I'm getting the following error:
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
I think that it is caused because, running the command into the active container, it can't find the var/run/docker.sock file, but I'm not sure about that, and I don't know hot to configure my container in the correct way to recognize this file.
I will add the complete response in the shell plus if it can help:
Activate the python shell: docker-compose exec app python manage.py shell_plus
>>> import docker
>>> client = docker.from_env()
>>> client.containers.run("ubuntu", "echo hello world")
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/local/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/site-packages/docker/transport/unixconn.py", line 42, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/local/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/site-packages/docker/transport/unixconn.py", line 42, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/docker/models/containers.py", line 766, in run
detach=detach, **kwargs)
File "/usr/local/lib/python3.6/site-packages/docker/models/containers.py", line 824, in create
resp = self.client.api.create_container(**create_kwargs)
File "/usr/local/lib/python3.6/site-packages/docker/api/container.py", line 411, in create_container
return self.create_container_from_config(config, name)
File "/usr/local/lib/python3.6/site-packages/docker/api/container.py", line 421, in create_container_from_config
res = self._post_json(u, data=config, params=params)
File "/usr/local/lib/python3.6/site-packages/docker/api/client.py", line 257, in _post_json
return self._post(url, data=json.dumps(data2), **kwargs)
File "/usr/local/lib/python3.6/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/docker/api/client.py", line 194, in _post
return self.post(url, **self._set_request_timeout(kwargs))
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Thank you so much.
I found a solution, a lot of time after. It's just necessary to include
- /var/run/docker.sock:/var/run/docker.sock
in the volumes list of the web service.
version: '2'
services:
web:
build: .
image: djangobase
command: python manage.py runserver 0.0.0.0:8000
ports:
- "3000:3000"
- "8000:8000"
volumes:
- .:/code
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- migration
- db
db:
image: postgres:10.1
volumes:
- .:/tmp/data/
migration:
image: djangobase
command: python manage.py migrate --noinput
volumes:
- .:/code
depends_on:
- db
I am getting the following error while installing graphlab in ubuntu 14.04. I already spent lot of time to solve this problem by googling it. can any one help me to solve this prblem.
Error:
ramy#ramy-Aspire-4739Z:~$ sudo pip install --upgrade https://get.graphlab.com/GraphLab-Create/2.1/mohangtrichy#gmail.com/<KEY>/GraphLab-Create-License.tar.gz
Downloading/unpacking https://get.graphlab.com/GraphLab-Create/2.1/mohangtrichy#gmail.com/<KEY>/GraphLab-Create-License.tar.gz
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 546, in unpack_http_url
resp = session.get(target_url, stream=True)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 467, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 558, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/adapters.py", line 385, in send
raise SSLError(e)
SSLError: [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
Storing debug log for failure in /home/ramy/.pip/pip.log
ramy#ramy-Aspire-4739Z:~$
Requests can verify SSL certificates for HTTPS requests, just like a
web browser. To check a host’s SSL certificate, you can use the verify
argument:
And if you want to avoid the SSLError you can find the requests part and change verify to False:
requests.get('https://google.com', verify=False)
Another way reinstall certifi module:
sudo pip uninstall -y certifi
sudo pip install certifi==2015.04.28
Have a look at these questions:
Python Requests throwing up SSLError
SSLError: bad handshake, Python requests