Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ConnectionError(';<;urllib3.connection.HTTPSConnection对象位于0x7f3a5d760390>;:未能建立新连接:[Errno 111]连接被拒绝';)_Python - Fatal编程技术网

Python ConnectionError(';<;urllib3.connection.HTTPSConnection对象位于0x7f3a5d760390>;:未能建立新连接:[Errno 111]连接被拒绝';)

Python ConnectionError(';<;urllib3.connection.HTTPSConnection对象位于0x7f3a5d760390>;:未能建立新连接:[Errno 111]连接被拒绝';),python,Python,我面临FHIR_解析器使用的urllib的连接错误。此错误发生在对接受患者id的端点的GET请求中。链接到存储库: 请求-2.24.0,urllib3版本:1.25.10,python:3.7 >> from fhir_parser import FHIR >> fhir = FHIR() >> patient = fhir.get_patient('8f789d0b-3145-4cf2-8504-13159edaa747') 连接错误 Error Trac

我面临FHIR_解析器使用的urllib的连接错误。此错误发生在对接受患者id的端点的GET请求中。链接到存储库:

请求-2.24.0,urllib3版本:1.25.10,python:3.7

>> from fhir_parser import FHIR
>> fhir = FHIR()
>> patient = fhir.get_patient('8f789d0b-3145-4cf2-8504-13159edaa747')
连接错误

Error
Traceback (most recent call last):
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, 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 "/home/joel/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connection.py", line 309, in connect
conn = self._new_conn()
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: 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 "/home/joel/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/joel/.local/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=5001): Max retries exceeded with url: /api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: 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 "", line 1, in
File "/home/joel/.local/lib/python3.7/site-packages/fhir_parser/fhir.py", line 73, in get_patient
response = requests.get(urllib.parse.urljoin(self.endpoint, 'Patient/' + str(id)), verify=self.verify_ssl)
File "/home/joel/.local/lib/python3.7/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/home/joel/.local/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/joel/.local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/joel/.local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/joel/.local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='localhost', port=5001): Max retries exceeded with url: /api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3a5d760390>: Failed to establish a new connection: [Errno 111] Connection refused'))
错误
回溯(最近一次呼叫最后一次):
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connection.py”,第160行,位于康涅狄格州的新州
(self.\u dns\u主机,self.port),self.timeout,**额外\u千瓦
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/util/connection.py”,第84行,在create_connection中
提出错误
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/util/connection.py”,第74行,在create_connection中
sock.connect(sa)
ConnectionRefusedError:[Errno 111]连接被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connectionpool.py”,第677行,在urlopen中
分块的,
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connectionpool.py”,第381行,在请求中
自我验证连接(连接)
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connectionpool.py”,第978行,位于康涅狄格州
连接
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connection.py”,第309行,在connect中
conn=自我。_new_conn()
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/connection.py”,第172行,位于康涅狄格州的新州
self,“无法建立新连接:%s”%e
urllib3.exceptions.NewConnectionError::无法建立新连接:[Errno 111]连接被拒绝
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/home/joel/.local/lib/python3.7/site packages/requests/adapters.py”,第449行,在send中
超时=超时
urlopen中的文件“/home/joel/.local/lib/python3.7/site packages/urlib3/connectionpool.py”,第727行
方法,url,error=e,_pool=self,_stacktrace=sys.exc_info()[2]
文件“/home/joel/.local/lib/python3.7/site packages/urllib3/util/retry.py”,第439行,增量
引发MaxRetryError(_池、url、错误或响应错误(原因))
urllib3.exceptions.MaxRetryError:HTTPSConnectionPool(host='localhost',port=5001):url超过最大重试次数:/api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747(由NewConnectionError引起(':未能建立新连接:[Errno 111]连接被拒绝])
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/home/joel/.local/lib/python3.7/site packages/fhir\u parser/fhir.py”,第73行,在get\u patient中
response=requests.get(urllib.parse.urljoin(self.endpoint,'Patient/'+str(id)),verify=self.verify\u ssl)
get中第76行的文件“/home/joel/.local/lib/python3.7/site packages/requests/api.py”
返回请求('get',url,params=params,**kwargs)
文件“/home/joel/.local/lib/python3.7/site packages/requests/api.py”,请求中的第61行
return session.request(method=method,url=url,**kwargs)
文件“/home/joel/.local/lib/python3.7/site packages/requests/sessions.py”,请求中的第530行
resp=自我发送(准备,**发送)
文件“/home/joel/.local/lib/python3.7/site packages/requests/sessions.py”,第643行,在send中
r=适配器.send(请求,**kwargs)
文件“/home/joel/.local/lib/python3.7/site packages/requests/adapters.py”,第516行,在send中
raise ConnectionError(e,请求=请求)
requests.exceptions.ConnectionError:HTTPSConnectionPool(host='localhost',port=5001):url:/api/Patient/8f789d0b-3145-4cf2-8504-13159edaa747超出了最大重试次数(由NewConnectionError引起(':未能建立新连接:[Errno 111]连接被拒绝])

此库只是FHIR客户端,没有服务器。所以您必须提供FHIR服务器的地址/URL,默认情况下,它希望服务器在本地主机和端口5001上运行,并使用类似
https://localhost:5001/api/
。或者您需要自己在本地主机上运行FHIR服务器

from fhir_parser import FHIR
fhir = FHIR(endpoint = 'https://SomeServer.com:SomePort/api/')
print(fhir.get_patient('8f789d0b-3145-4cf2-8504-13159edaa747'))

看起来您的库希望某些服务器在端口5001上的本地计算机上运行。看看库中的描述,可能你们需要运行一些命令来启动服务器,或者你们应该联系一些服务器来接收数据。因为库从远程服务器下载数据。默认情况下,服务器可能正在本地主机上运行。