What would cause this error to appear suddenly whe...
# ask-community
j
What would cause this error to appear suddenly when running flows locally in Anaconda? I've been able to run them for 1+ year just fine and never had this issue.
n
Hi @Jason Motley hmm that's strange - you don't have a local module that happens to be called "prefect" do you?
j
I do not. IT also was working fine just last week and "task" is the only part that appears to not be recognized.
n
could you share your
prefect --version
output?
j
This is what I get with conda list
prefect 0.15.9
n
hmm. would you be able to install
prefect==1.4.1
? with
pip install 'prefect<2.0'
j
Might that mess with whatever prefect version my company uses ?
As far as connecting to cloud secrets
n
i dont believe there’d be any breaking changes between 0.15.9 and 1.4.1 (there definitely would if you went up to a 2.x.x version) as far as retrieving secrets stored in cloud is concerned.
j
Okay, I can try that, thanks!
Do I uninstall first or just run conda install?
n
i believe you can just do ‘conda install prefect==1.4.1’
j
Same error
n
hmm - in the environment where you're trying to run the flow, can you do any prefect cli commands? e.g.
prefect --help
j
Yup those work
I checked the init file that the error references and there are several items that appear as yellow i.e. not in the package
n
could do you
where prefect
and
where python
? (wait, sorry, I have to find what these are on windows)
j
Prefect:
C:\Users\JasonMotley\.conda\envs\prefectenv\Scripts\prefect.exe
Python (I'm on anaconda):
Copy code
C:\Users\JasonMotley\.conda\envs\prefectenv\python.exe
C:\Users\JasonMotley\AppData\Local\Microsoft\WindowsApps\python.exe
n
jeez - I'm not so sure what's going on there, looks normal from what I know about conda on windows. other things I'd try if I was in your position • delete / recreate conda env • uninstall any versions of prefect that exist outside of your virtual environments if you're still running into trouble, I'd be happy to hop on a huddle with you tomorrow and see if we can figure it out
j
Okay, I'll see what I can figure out. Appreciate the help!
👍 1
I did have an idea based on the error. If the
init
file cannot find the
tasks
file, can I just manually edit that file so it CAN find it?
init says to look here: from prefect.utilities.tasks
n
hmm - personally I wouldn't modify
__init__
ahh wait, is your file containing your flow named
uuid.py
? what if you try a different name?
Copy code
(prefect-1)
❯ python uuid1.py # success!

(prefect-1)
❯ mv uuid1.py uuid.py

(prefect-1)
❯ cat uuid.py
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: uuid.py
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │
   2   │ from prefect import task
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

(prefect-1)
❯ python uuid.py
Traceback (most recent call last):
  File "uuid.py", line 2, in <module>
    from prefect import task
  File "/Users/nate/opt/miniconda3/envs/prefect-1/lib/python3.8/site-packages/prefect/__init__.py", line 1, in <module>
    import prefect.utilities
  File "/Users/nate/opt/miniconda3/envs/prefect-1/lib/python3.8/site-packages/prefect/utilities/__init__.py", line 1, in <module>
    import prefect.utilities.logging
  File "/Users/nate/opt/miniconda3/envs/prefect-1/lib/python3.8/site-packages/prefect/utilities/logging.py", line 21, in <module>
    from uuid import uuid4
  File "/Users/nate/src/play/testing-prefect/uuid.py", line 2, in <module>
    from prefect import task
ImportError: cannot import name 'task' from partially initialized module 'prefect' (most likely due to a circular import) (/Users/nate/opt/miniconda3/envs/prefect-1/lib/python3.8/site-packages/prefect/__init__.py)
j
That worked! Thank you so, so much.
🦜 1
n
awesome! glad i could help generally, id try to avoid naming script files the same as standard library modules (like uuid, datetime, etc), bc it can lead to tricky bugs like this 🙂