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

[bug][4.12.2][Notebook] cannot import name 'TypeIs' from 'typing_extensions' #510

Closed
sl-ffx opened this issue Nov 21, 2024 · 4 comments
Closed

Comments

@sl-ffx
Copy link

sl-ffx commented Nov 21, 2024

I am using Fabric Notebook and I want to use the openai package but I get an error on importing it. (installing openai with --upgrade also upgrades typing_extensions to version 4.12.2)

!pip install openai --upgrade
import openai
ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages/typing_extensions.py)

The same error occurs on importing TypeIs.

from typing_extensions import TypeIs

The weird thing is, that the /home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages/typing_extensions.py contains the TypeIs in the __all__ variable but when I execute the following code I cannot find TypeIs in the resulting array.

import typing_extensions
dir(typing_extensions)

I am using typing_extensions v4.12.2 and python v3.11.8

!pip show typing_extensions
!python --version

Name: typing_extensions
Version: 4.12.2
Summary: Backported and Experimental Type Hints for Python 3.8+
Home-page: 
Author: 
Author-email: "Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Michael Lee" <[email protected]>
License: 
Location: /home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages
Requires: 
Required-by: alembic, azure-core, azure-storage-blob, azure-storage-file-datalake, dash, huggingface_hub, lightning-utilities, mypy, nni, openai, pydantic, pydantic_core, pytorch-lightning, SQLAlchemy, torch, typeguard
Python 3.11.8

I've run out of ideas on how to solve the problem. It worked yesterday and today I cannot import it any longer.

This has to be an issue with Fabric Notebook because everything works fine locally on my device. But maybe you have an idea how to solve it in Notebook.

@srittau
Copy link
Collaborator

srittau commented Nov 21, 2024

This sounds like an environmental problem where the wrong version of the library is picked up. You could check that by printing typing_extensions.__file__ and see whether the correct file is picked up.

@sl-ffx
Copy link
Author

sl-ffx commented Nov 21, 2024

import typing_extensions

print(typing_extensions.__file__)
/home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages/typing_extensions.py

That's the same file as mentioned above.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Nov 21, 2024

It's probably already imported in your notebook process before the time you install the newer version

There's not really anything we can do to help you in this issue tracker

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2024
@sl-ffx
Copy link
Author

sl-ffx commented Nov 21, 2024

Thanks for your feedback. I solved the problem and want to add the information here if someone else has the same problem:

I contacted the support of Fabric and they responded with the following suggestion:

Could you please use %pip install openai instead of ! pip install openai.

We recommend %pip instead of !pip. !pip is an IPython built-in shell command, which has the following limitations:
!pip only installs a package on the driver node, not executor nodes.
Packages that install through !pip don't affect conflicts with built-in packages or whether packages are already imported in a notebook.

To solve the problem I had to replace

!pip install openai --upgrade

with

%pip install openai --upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants