Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DaskFinder in Colab prevents importing packages #5141

Open
mhucka opened this issue Feb 28, 2025 · 4 comments
Open

DaskFinder in Colab prevents importing packages #5141

mhucka opened this issue Feb 28, 2025 · 4 comments
Labels

Comments

@mhucka
Copy link

mhucka commented Feb 28, 2025

Describe the current behavior

Attempting to run the following on both https://colab.research.google.com and https://colab.sandbox.google.com/,

try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet cirq
    import cirq

results in an error that appears to be coming from Dask:

[<ipython-input-5-98520f192a76>](https://localhost:8080/#) in <cell line: 0>()
----> 1 import cirq

8 frames
[/usr/local/lib/python3.11/dist-packages/cirq/__init__.py](https://localhost:8080/#) in <module>
     30 )
     31 
---> 32 with _import.delay_import('cirq.protocols'):
     33     from cirq import (
     34         # Core

[/usr/lib/python3.11/contextlib.py](https://localhost:8080/#) in __enter__(self)
    135         del self.args, self.kwds, self.func
    136         try:
--> 137             return next(self.gen)
    138         except StopIteration:
    139             raise RuntimeError("generator didn't yield") from None

[/usr/local/lib/python3.11/dist-packages/cirq/_import.py](https://localhost:8080/#) in delay_import(module_name)
    164 
    165     with wrap_module_executions(module_name, wrap_func):
--> 166         importlib.import_module(module_name)
    167 
    168     yield  # Run the body of the context

[/usr/lib/python3.11/importlib/__init__.py](https://localhost:8080/#) in import_module(name, package)
    124                 break
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 
    128 

/usr/lib/python3.11/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/lib/python3.11/importlib/_bootstrap.py in _find_and_load(name, import_)

/usr/lib/python3.11/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

/usr/lib/python3.11/importlib/_bootstrap.py in _find_spec(name, path, target)

[/usr/local/lib/python3.11/dist-packages/cirq/_import.py](https://localhost:8080/#) in find_spec(self, fullname, path, target)
     64     def find_spec(self, fullname: str, path: Any = None, target: Any = None) -> Any:
     65         components = fullname.split('.')
---> 66         spec = self.finder.find_spec(fullname, path=path, target=target)
     67         if spec is None:
     68             return None

TypeError: DaskFinder.find_spec() got an unexpected keyword argument 'path'

Everyone in our group, using Colab in 2 cities, is experiencing this right now, and it's a recent change.

What web browser you are using

I'm using Google Chrome (internal version).

@mhucka mhucka added the bug label Feb 28, 2025
@mayankmalik-colab
Copy link
Contributor

Thanks for reporting this. Yes, it seems like an issue. Tracking internally b/399860199 .

@mayankmalik-colab
Copy link
Contributor

@mhucka - A workaround for now would be to use a fallback runtime. I just tested it on a fallback and it works. You can check how to use a fallback here if you haven't used it before.

@pavoljuhas
Copy link

Another workaround for colabs that need Cirq, but do not import dask is

import sys
sys.meta_path[:] = [f for f in sys.meta_path if "DaskFinder" not in str(f)]

Root cause fix suggested at rapidsai/rapids-dask-dependency#90

@Wensenber
Copy link

if it works!

Image

@mhucka mhucka changed the title DaskFinder error right now in Colab DaskFinder in Colab prevents importing packages Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants