如何解决Mac上运行Python时的导入错误?

2024-09-30 14:20:41 发布

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

这是一个错误。我正在使用Python从Snowflake进行查询,它在MAC OS上

import snowflake.connector as sf
from config import config

conn =sf.connect(user=config.username,password=config.password,account=config.account)

错误如下

"/Users/xxxxxx/Snowflake Project/bin/python" "/Users/xxxxxx/PycharmProjects/Snowflake Project/Snowflake_selectrecord.py"
Traceback (most recent call last):
  File "/Users/xxxxxx/PycharmProjects/Snowflake Project/Snowflake_selectrecord.py", line 2, in <module>
    from config import config
ImportError: cannot import name 'config' from 'config' (/Users/xxxxxx/PycharmProjects/Snowflake Project/config.py)

Process finished with exit code 1

我是Python新手,无法摆脱这个错误。我搜索了论坛,没有得到解决我错误的回复

Config.py:

username='xxxxx'
password=''
account='xxxxxxxedo.us-east-1'
warehouse= 'reporting_wh'
database='reporting_nonprod'

Tags: frompyimportprojectconfig错误usernameaccount