英文:
In DBT I cannot import name 'RuntimeException' from 'dbt.exceptions'
问题
我尝试在EC2实例上设置dbt,创建一个conda环境:
conda create --name dbt-athena python=3.10
conda activate dbt-athena
conda install -c conda-forge dbt-athena-adapter
然后我看到dbt已经正确安装:
dbt --version
Core:
- installed: 1.5.1
- latest: 1.5.2 - Update available!
所以我尝试初始化一个项目:
dbt init gapminder
15:08:31 Running with dbt=1.5.1
The profile gapminder already exists in /home/ec2-user/.dbt/profiles.yml. Continue and overwrite it? [y/N]: y
Which database would you like to use?
[1] athena
(Don't see the one you want? https://docs.getdbt.com/docs/available-adapters)
但是我遇到了这个错误:
15:08:55 Encountered an error:
cannot import name 'RuntimeException' from 'dbt.exceptions' (/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/exceptions.py)
15:08:55 Traceback (most recent call last):
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/requires.py", line 86, in wrapper
result, success = func(*args, **kwargs)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/requires.py", line 71, in wrapper
return func(*args, **kwargs)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/main.py", line 457, in init
results = task.run()
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/task/init.py", line 305, in run
self.create_profile_from_target(adapter, profile_name=project_name)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/task/init.py", line 173, in create_profile_from_target
load_plugin(adapter)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/factory.py", line 202, in load_plugin
return FACTORY.load_plugin(name)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/factory.py", line 57, in load_plugin
mod: Any = import_module("." + name, "dbt.adapters")
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/athena/__init__.py", line 1, in <module>
from dbt.adapters.athena.connections import AthenaConnectionManager
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/athena/connections.py", line 22, in <module>
from dbt.exceptions import RuntimeException, FailedToConnectException
ImportError: cannot import name 'RuntimeException' from 'dbt.exceptions' (/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/exceptions.py)
我检查了我的profiles.yml文件:
gapminder:
outputs:
dev:
aws_profile_name: ec2-user
database: awsdatacatalog
region_name: us-east-1
s3_data_dir: s3://mybucket/results/
s3_staging_dir: s3://mybucket/results/
schema: myschema
threads: 1
type: athena
target: dev
所以我无法创建这个项目。请帮助将不胜感激。
英文:
I tried to setup dbt on a EC2 instance, creating an conda environment:
conda create --name dbt-athena python=3.10
conda activate dbt-athena
conda install -c conda-forge dbt-athena-adapter
Then I see dbt is installed correctly:
dbt --version
Core:
- installed: 1.5.1
- latest: 1.5.2 - Update available!
So I tried to initialize a project:
dbt init gapminder
15:08:31 Running with dbt=1.5.1
The profile gapminder already exists in /home/ec2-user/.dbt/profiles.yml. Continue and overwrite it? [y/N]: y
Which database would you like to use?
[1] athena
(Don't see the one you want? https://docs.getdbt.com/docs/available-adapters)
But I get this error:
15:08:55 Encountered an error:
cannot import name 'RuntimeException' from 'dbt.exceptions' (/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/exceptions.py)
15:08:55 Traceback (most recent call last):
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/requires.py", line 86, in wrapper
result, success = func(*args, **kwargs)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/requires.py", line 71, in wrapper
return func(*args, **kwargs)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/cli/main.py", line 457, in init
results = task.run()
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/task/init.py", line 305, in run
self.create_profile_from_target(adapter, profile_name=project_name)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/task/init.py", line 173, in create_profile_from_target
load_plugin(adapter)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/factory.py", line 202, in load_plugin
return FACTORY.load_plugin(name)
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/factory.py", line 57, in load_plugin
mod: Any = import_module("." + name, "dbt.adapters")
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/athena/__init__.py", line 1, in <module>
from dbt.adapters.athena.connections import AthenaConnectionManager
File "/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/adapters/athena/connections.py", line 22, in <module>
from dbt.exceptions import RuntimeException, FailedToConnectException
ImportError: cannot import name 'RuntimeException' from 'dbt.exceptions' (/home/ec2-user/miniconda3/envs/dbt-athena/lib/python3.10/site-packages/dbt/exceptions.py)
I checked up my profiles.yml file:
gapminder:
outputs:
dev:
aws_profile_name: ec2-user
database: awsdatacatalog
region_name: us-east-1
s3_data_dir: s3://mybucket/results/
s3_staging_dir: s3://mybucket/results/
schema: myschema
threads: 1
type: athena
target: dev
So I can't create this project. Please, any help will be greatly appreciated.
答案1
得分: 1
这可能是依赖项或实用程序版本不匹配的问题。
在将dbt升级到1.5或更高版本后,我遇到了相同的错误。然而,一旦我更新了Snowflake适配器,问题就消失了:
pip install --upgrade dbt-snowflake
英文:
This could be a dependency or utility version mismatch issue.
I got the same error after I upgraded dbt to v 1.5 or higher. However, the issue went away once I updated the snowflake adaptor:
pip install --upgrade dbt-snowflake
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论