Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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 sp_execute_external_脚本可以';找不到由setuptools安装的模块_Python_Sql Server_Setuptools_Egg - Fatal编程技术网

Python sp_execute_external_脚本可以';找不到由setuptools安装的模块

Python sp_execute_external_脚本可以';找不到由setuptools安装的模块,python,sql-server,setuptools,egg,Python,Sql Server,Setuptools,Egg,我正在积极开发一个Python模块,我希望在本地安装的SQL Server 2017中部署该模块,因此我在c:\Program Files\Microsoft SQL Server\\Python\u SERVICES\Lib\site packages中部署该模块,使用setuptools如下: "c:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\python" setup.py develo

我正在积极开发一个Python模块,我希望在本地安装的SQL Server 2017中部署该模块,因此我在
c:\Program Files\Microsoft SQL Server\\Python\u SERVICES\Lib\site packages
中部署该模块,使用
setuptools
如下:

"c:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\python" setup.py develop
下面是相应的
setup.cfg
文件:

[metadata]
name = <module_name>
description = <Module Description>
description-file = README.md
description-content-type = text/markdown

[files]
package_root = py/src
有了这个部署,我希望将刚刚通过
.egg link
发布的模块导入
sp\u execute\u external\u script
调用,如下所示:

execute sp_execute_external_script @language= N'Python', @script= N'from <module_name>.uploader import Upload';
execute sp_execute_external_script@language=N'Python',@script=N'from.uploader import Upload';
但是,从SSMS执行此存储过程会产生以下错误消息:

Msg 39004, Level 16, State 20, Line 10
A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 10
An external script error occurred: 

Error in execution.  Check the output for more information.
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\SQL-MSSQLSERVER-ExtensibilityData-PY\MSSQLSERVER01\C08BB9A7-66B5-4B5E-AAFC-B0248EE64199\sqlindb.py", line 27, in transform
    from <module_name>.uploader import Upload
ImportError: No module named '<module_name>'

SqlSatelliteCall error: Error in execution.  Check the output for more information.
STDOUT message(s) from external script: 
SqlSatelliteCall function failed. Please see the console output for more information.
Traceback (most recent call last):
  File "C:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 587, in rx_sql_satellite_call
    rx_native_call("SqlSatelliteCall", params)
  File "C:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\lib\site-packages\revoscalepy\RxSerializable.py", line 358, in rx_native_call
    ret = px_call(functionname, params)
RuntimeError: revoscalepy function failed.
Msg 39004,第16级,状态20,第10行
使用HRESULT 0x80004004执行“sp_执行_外部_脚本”期间发生“Python”脚本错误。
Msg 39019,16级,状态2,第10行
发生外部脚本错误:
执行错误。检查输出以了解更多信息。
回溯(最近一次呼叫最后一次):
文件“”,第5行,在
文件“C:\SQL MSSQLSERVER扩展性数据PY\MSSQLSERVER01\C08BB9A7-66B5-4B5E-AAFC-B0248EE64199\sqlindb.PY”,第27行,在转换中
从.uploader导入上载
ImportError:没有名为“”的模块
SqlSatelliteCall错误:执行中出错。检查输出以了解更多信息。
来自外部脚本的标准输出消息:
SqlSatelliteCall函数失败。有关更多信息,请参阅控制台输出。
回溯(最近一次呼叫最后一次):
rx\U SQL\U satellite\U调用中的文件“C:\Program Files\Microsoft SQL Server\\PYTHON\U SERVICES\lib\site packages\revoscalepy\computecontext\RxInSqlServer.py”,第587行
rx_本地_调用(“SqlSatelliteCall”,参数)
文件“C:\Program Files\Microsoft SQL Server\\PYTHON\u SERVICES\lib\site packages\revoscalepy\RxSerializable.py”,第358行,在rx\u native\u调用中
ret=px_调用(函数名,参数)
运行时错误:revoscalepy函数失败。
显然,我已经从错误消息中编辑了
模块名称
实例名称

我尝试使用
install
命令而不是
develope
,只是为了确保
.egg链接
文件没有问题
install
站点软件包中安装
.egg info
文件,但我收到了相同的错误

我还尝试从混音中删除
pbr
,但得到了相同的错误

最后,我尝试按照建议将我的
添加到
sys.path
,但也没有任何帮助

所以在这一点上,我不知道我可能做错了什么

python版本是
3.5.2
,我认为项目中不需要
\uuu init\uuu.py
,就可以将其作为一个模块。在
py/src
中插入空白的
\uuuu init\uuuu.py
也没有帮助


我的
pip
版本是
19.3.1
setuptools
版本是
44.0
pbr
版本是
5.4.4
,我已经确认所有模块都安装在上面提到的
站点包
目录中。

基于我的大量实验,似乎
sp\u execute\u external\u脚本
不遵循符号链接(即通过
.egg链接
文件)。因此,无论您使用的是
setuptools
pip
pbr
还是其他任何工具,开发模式安装都无法正常工作

我甚至尝试将
文件夹作为操作系统符号链接。因为我在Windows上,所以我在命令提示符下使用了
mklink/D
命令将
/py/src/
内部
站点包
。虽然命令正确执行,并且我可以在文件资源管理器中看到符号链接的文件夹,
sp\u execute\u external\u script
无法检测包。这告诉我,
sp\u execute\u external\u script
代码中可能有某种东西可以避免遍历符号链接

我想知道是否有办法让它穿越符号链接

唯一可行的解决方案是在自己的目录下开发包的代码,因此,在我的例子中,
/py/src/
。然后,在运行
exec sp\u execute\u external\u script@language=N'python',@script=N'…'
之前,将
文件夹复制到
站点包
目录

这在某种程度上相当于
setup.py安装
,但绕过了中间文件和目录的创建。因此,我将坚持这种简单的——尽管令人厌恶的——方法


我希望更有知识的人能提供更好的方法来解决这个问题。

根据我的大量实验,似乎
sp\u execute\u external\u script
不遵循符号链接(即通过
.egg链接
文件)。因此,无论您使用的是
setuptools
pip
pbr
还是其他任何工具,开发模式安装都无法正常工作

我甚至尝试将
文件夹作为操作系统符号链接。因为我在Windows上,所以我在命令提示符下使用了
mklink/D
命令将
/py/src/
内部
站点包
。虽然命令正确执行,并且我可以在文件资源管理器中看到符号链接的文件夹,
sp\u execute\u external\u script
无法检测包。这告诉我,
sp\u execute\u external\u script
代码中可能有某种东西可以避免遍历符号链接

我想知道是否有办法让它穿越符号链接

唯一可行的解决方案是在自己的目录下开发包的代码,因此,在我的例子中,
/py/src/
。然后,在运行
exec sp\u execute\u external\u script@language=N'python',@script=N'…'
之前,将
文件夹复制到
站点包
目录

这相当于
setup.py安装execute sp_execute_external_script @language= N'Python', @script= N'from <module_name>.uploader import Upload';
Msg 39004, Level 16, State 20, Line 10
A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 10
An external script error occurred: 

Error in execution.  Check the output for more information.
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\SQL-MSSQLSERVER-ExtensibilityData-PY\MSSQLSERVER01\C08BB9A7-66B5-4B5E-AAFC-B0248EE64199\sqlindb.py", line 27, in transform
    from <module_name>.uploader import Upload
ImportError: No module named '<module_name>'

SqlSatelliteCall error: Error in execution.  Check the output for more information.
STDOUT message(s) from external script: 
SqlSatelliteCall function failed. Please see the console output for more information.
Traceback (most recent call last):
  File "C:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\lib\site-packages\revoscalepy\computecontext\RxInSqlServer.py", line 587, in rx_sql_satellite_call
    rx_native_call("SqlSatelliteCall", params)
  File "C:\Program Files\Microsoft SQL Server\<Instance_Name>\PYTHON_SERVICES\lib\site-packages\revoscalepy\RxSerializable.py", line 358, in rx_native_call
    ret = px_call(functionname, params)
RuntimeError: revoscalepy function failed.