Python OSError:[WinError 10013]试图以其访问权限所禁止的方式访问套接字

2024-05-16 03:01:15 发布

您现在位置:Python中文网/ 问答频道 /正文

因此我在这里发帖时不知所措。当我试图从WindowsCore上的服务器(vm)通过python从t-sql发出http/https web请求时,标题中出现了一个错误。我在其他线程中读到过,可能与防火墙相关,非管理员帐户无法绑定到较低的端口,到目前为止还没有取得任何进展。与我一起工作的系统管理员向我保证,主机服务器上没有防火墙,这可能会导致此错误或阻止python。我能够通过SSIS/C#脚本任务/sql代理作业使用相同的域帐户访问不同的rest API,没有任何问题

代码的示例版本:

execute sp_execute_external_script
@language = N'Python',
@script = N'
import requests

r = requests.get("https://www.google.com")
print(r.status_code)
'

错误:

Msg 39004, Level 16, State 20, Line 0
A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 0
An external script error occurred: 
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\revoscalepy\functions\RxSummary.py:4: FutureWarning: The Panel class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version
  from pandas import DataFrame, Index, Panel

Error in execution.  Check the output for more information.
Traceback (most recent call last):
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
    raise err
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection

Msg 39019, Level 16, State 2, Line 0
An external script error occurred: 
    sock.connect(sa)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

During handling of the above exception, another exception occurred:

已尝试以下操作但未成功:

  1. 使用域管理员帐户重新配置launchpad服务
  2. 已将域帐户添加到本地管理员组(即使域管理员已经是组的一部分)
  3. 添加MSSQLSlaunchPad作为本地管理员
  4. 已禁用windows防火墙和可能阻止通信的规则

有人能告诉我,一般来说,是什么导致了这个错误,以及可能如何解决我的具体情况吗


Tags: insqlserver管理员错误script帐户files