如何在Snowflake中安装不属于Anaconda的Python包。

huangapple go评论77阅读模式
英文:

How to install python package in snowflake which is not a part of anaconda

问题

I am working on decrypting files (.pgp) from a location in my ADLS, To do that I need to use private key that's in my azure keyvault, I am using Snowflake Python worksheet, as of now I want python library like pgpy, os, base64, azure_keyvault, azure_identity.
Is there any way I can import these libraries that's not a part of anaconda package.
I've staged these library as .whl files but i need help in importing these libraries in my worksheet.

我正在解密位于我的ADLS位置的文件(.pgp),为此我需要使用位于我的Azure密钥库中的私钥,我正在使用Snowflake Python工作表,目前我想要像pgpy、os、base64、azure_keyvault、azure_identity这样的Python库。
是否有办法可以导入这些不是Anaconda包的库。
我已经将这些库制作成了.well文件,但我需要帮助将它们导入我的工作表。

I've staged the .whl files of the required python package in my snowflake.
but struggling how to import them to my worksheet.
Is there any way to use them,
I've also tried sql stored procedure but its not working also
Can anyone help me in the complete step by step manner how to do that

我已经在我的Snowflake中准备了所需Python包的.well文件。
但我不知道如何将它们导入我的工作表。
有没有办法使用它们,
我还尝试过SQL存储过程,但也不起作用。
有人可以以完整的逐步方式帮助我吗?

Also, I've seen that if I staged .Py file we can simply use Import command. So, if I was able to convert the entire azure identity python package to one .py file I'll be able to import it import it directly.

此外,我注意到如果我将.Py文件进行分段,我们可以简单地使用Import命令。所以,如果我能够将整个Azure Identity Python包转换为一个.py文件,我就能够直接导入它。

Stagged files in snowflake here
python packages here

英文:

I am working on decrypting files (.pgp) from a location in my ADLS, To do that I need to use private key that's in my azure keyvault, I am using Snowflake Python worksheet, as of now I want python library like pgpy,os,base64,azure_keyvault,azure_identity.
Is there any way I can import these libraries that's not a part of anaconda package.
I've staged these library as .whl files but i need help in importing these libraries in my worksheet.

I've staged the .whl files of the required python package in my snowflake.
but struggling how to import them to my worksheet.
Is there any way to use them,
I've also tried sql stored procedure but its not working also
Can anyone help me in the complete step by stepo manner how to do that

Also, I've seen that if I staged .Py file we can simply use Import command. So, if I was able to convert the entire azure identity python package to one .py file I'll be able to import it import it directly.

Stagged files in snowflake here
python packages here

答案1

得分: 1

你想要类似这样的内容:

  1. 将包添加到阶段包
    如何在Snowflake中安装不属于Anaconda的Python包。
  2. 获取Snowflake导入目录
  3. 将轮子文件附加到系统路径
  4. 从库导入
import snowflake.snowpark as snowpark

# 将轮子添加到系统路径以启用阶段包导入
import sys
import_dir = sys._xoptions.get("snowflake_import_directory")
sys.path.append(import_dir + "python_ulid-1.1.0-py3-none-any.whl")
from ulid import ULID

def ulid(session: snowpark.Session):
  a_ulid = ULID()
  return str(a_ulid)
英文:

You want something like this

  1. Add the package to Stage Packages<br>
    如何在Snowflake中安装不属于Anaconda的Python包。
  2. Get the Snowflake import directory
  3. Append the wheel file to the system path
  4. Import from the library
import snowflake.snowpark as snowpark

# Add wheel to system path to enable stage package import
import sys
import_dir = sys._xoptions.get(&quot;snowflake_import_directory&quot;)
sys.path.append(import_dir + &quot;python_ulid-1.1.0-py3-none-any.whl&quot;)
from ulid import ULID

def ulid(session: snowpark.Session):
  a_ulid = ULID()
  return str(a_ulid)

huangapple
  • 本文由 发表于 2023年7月18日 13:43:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76709797.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定