英文:
Import Python Packages in SnowFlake to be Used Python Worksheets
问题
我已成功按照以下指南安装了一个Python包:
https://medium.com/snowflake/running-pip-packages-in-snowflake-d43581a67439
然而,结果与我预期的完全相同。
我希望在将Python Wheel导入SnowFlake后,该包会出现在这里
但是,正如您所见,没有添加任何包。
我相信,如果按照图像中所示添加了该包,我将能够从SnowFlake Python工作表中执行以下代码行:
from faker_biology.physiology import CellType, Organ, Organelle
from faker import Faker
但我一直收到ModuleNotFoundError错误。
所以,是否有人可以告诉我如何添加一个可以从SnowFlake Python工作表中访问的Python包呢?
英文:
I have successfully installed a Python package using the following guide:
https://medium.com/snowflake/running-pip-packages-in-snowflake-d43581a67439
However, the outcome is exactly what I was expecting.
I was hoping that after importing the Python Wheel into SnowFlake the package would appear here
But as you can see no packages were added.
I believe if the package was added as shown in the image I would be able to execute the following lines of code from a SnowFlake Python Worksheet:
from faker_biology.physiology import CellType, Organ, Organelle
from faker import Faker
But I keep on getting the error ModuleNotFoundError
So, can someone let me know how to add a Python Package that will accessible from a SnowFlake Python Worksheet?
答案1
得分: 1
I could run it inside Python worksheet without any issues:
import snowflake.snowpark as snowpark
from faker import Faker
import wheel_loader
def fake(locale,provider,parameters):
wheel_loader.load('faker_biology-0.6.0-py3-none-any.whl')
from faker_biology.physiology import CellType
if type(parameters).__name__=='sqlNullWrapper':
parameters = {}
fake = Faker(locale=locale)
fake.add_provider(CellType)
return fake.format(formatter=provider,**parameters)
def main(session: snowpark.Session):
return fake('en_US','celltype',{})
Output:
|PYTHON_WORKSHEET|
|---|
|Starburst amacrine cells|
Anaconda package:
Stage Packages:
Output:
英文:
I could run it inside Python worksheet without any issues:
import snowflake.snowpark as snowpark
from faker import Faker
import wheel_loader
def fake(locale,provider,parameters):
wheel_loader.load('faker_biology-0.6.0-py3-none-any.whl')
from faker_biology.physiology import CellType
if type(parameters).__name__=='sqlNullWrapper':
parameters = {}
fake = Faker(locale=locale)
fake.add_provider(CellType)
return fake.format(formatter=provider,**parameters)
def main(session: snowpark.Session):
return fake('en_US','celltype',{})
Output:
PYTHON_WORKSHEET |
---|
Starburst amacrine cells |
Anaconda package:
Stage Packages:
Output:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论