I am getting a `cannot import name 'Definitions' f...
# ask-community
p
I am getting a
cannot import name 'Definitions' from 'dagster'
error when attempting to use the Definitions method to load code... Am I doing something wrong?
d
Hi @PPP, which version of dagster are you running? Can you check with
dagster --version
please?
p
Copy code
(dagster) ➜  ~ dagster --version
dagster, version 1.3.5
r
This looks like an issue with your python environment — I recommend that you have
pyenv
or
virtualenv
set up. This should be a legitimate import:
Copy code
from dagster import Definitions
p
Oh so it doesn't work with conda
d
It should work with Conda too, but looks like you haven't activated your conda environment, or similar
p
that dagster in bracket
(dagster)
is my conda env
any other recommendations?
o
hi @PPP -- at what point in time are you seeing this error? is it when you run `dagit`/`dagster dev`, or some other time? I agree w/ rex that this seems to be an issue with your python environment. Some things to try running: • `which dagit`/`which dagster` in the terminal will tell you where your terminal is going to invoke these commands (I'd expect it to be somewhere in your conda environment, but things can get scrambled sometimes) • in a python shell:
Copy code
from dagster import __version__
print(__version__)
should tell you the version that dagster thinks it's running in. If that prints out
1.3.5
, then I'd expect you to be able to run
from dagster import Definitions
without issue
p
Copy code
(default-py38) ➜  p2e-poc git:(main) ✗ conda activate dagster
(dagster) ➜  p2e-poc git:(main) python3.11
Python 3.11.3 (main, Apr 19 2023, 18:51:09) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dagster import __version__
>>> print(__version__)
1.3.5
>>> from dagster import Definations
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Definations' from 'dagster' (/Users/u530241/miniconda3/versions/miniconda3-4.7.12/envs/dagster/lib/python3.11/site-packages/dagster/__init__.py)
>>>
r
you spelled the import wrong:
from dagster import Definitions
p
wohoo! it worked, thank you all
👌🏽 1
🌈 2