Why aren't transformers imported in Python? - python

I want to import transformers in jupyter notebook but I get the following error. What is the reason for this error? My Python version is 3.8
ImportError: cannot import name 'TypeAlias' from 'typing_extensions'
I also updated the typing-extensions library version, but the problem was not resolved

You could try
pip install typing-extensions --upgrade

maybe the probelm is the version of datasets package:
pip install datasets==1.15

TypeAlias is available from python version 3.10.
You should upgrade your python version to avoid the error.

Related

No module named 'bcolors' although 'Requirement already satisfied'

I am trying to use bcolors in my python code in Spyder/Anaconda but it keeps telling me
ModuleNotFoundError: No module named 'bcolors'.
So I installed it with pip install bcolorswhich gave me Requirement already satisfied: bcolors in e:\anaconda3\lib\site-packages (1.0.4), but it still doesn't work.
What am I doing wrong?
You had that error because you are in different interpreter trying to import the module. You should append the path of the module to your working directory.
import sys
sys.path.append("\anaconda3\lib\site-packages")
import bcolors
Try to install lower version of this module
pip install bcolors==1.0.2
Have you tried installing the pandas' library using pip install pandas
I was having trouble with the latest distribution as well. Installing 1.0.2 worked for me.

Can't import object detection imageai (python)

I installed imageai,tensorflow,keras in python with pip
i typed this code
from imageai.Detection import ObjectDetection
it shows this error
ModuleNotFoundError: No module named 'keras.layers.advanced_activations'
module versions
imageai - 2.0.2
keras - 2.90
tensorflow - 2.9.1
im running on windows 10 pro
Try to update version of imageai to new versions.
try this
As imageai now uses Pytorch in backend, you must install a few library dependencies before installing imageai. Please refer to this link for the same.
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
Import the Object detection api from imageai
from imageai.Detection import ObjectDetection
Let us know if the issue still persists. Thank you.

ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection'

I imported sklearn DecisionBoundaryDisplay via the below command in my Google Colab file.
from sklearn.inspection import DecisionBoundaryDisplay
And I'm getting the following error.
ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection'
I even installed the following packages & also tried by restarting my runtime but still I'm getting the error.
!pip install --upgrade scikit-learn
!pip install scipy
!pip3 install -U scikit-learn scipy matplotlib
How to fix this issue?
what worked for me was installing scikit learn 1.1.0, i had version 1.0.2 before and got the same error you're encountering.
pip install -U scikit-learn --user
Hope it helps.
It seems DecisionBoundaryDisplay is a new feature and it is currently in an unstable development version. To use it, you need to install the nightly build.

Pycaret cannot imported due to another import error

ImportError: cannot import name '_joblib_parallel_args' from 'sklearn.utils.fixes' (c:\users\ezgi\appdata\local\programs\python\python38\lib\site-packages\sklearn\utils\fixes.py)
To fix I update sklearn library. But, it don't work. Anyone know the reason behind it?
I update sklearn with
pip install --upgrade scikit-learn
Also, uninstall and install it with pip.
This is because one of pycaret's dependencies (imbalanced-learn) fails with the latest version of sklearn
https://github.com/scikit-learn-contrib/imbalanced-learn/issues/894
A temporary workaround until this is fixed would be to use a lower version of sklearn. If you are using pip install pycaret, then you need to use a version of sklearn < 1.0.0

Numpy version issue when using astropy

I am currentling trying to use a package I installed (stsynphot), but I have the following error when typing import stsynphot as stsyn
ImportError: Numpy version 1.9.0 or later must be installed to use Astropy
I was curious so just to try, I tried import astropy and of course had the same error.
Nevertheless, I do have numpy 1.14 installed, I have tried all the upgrade and reinstall procedures but I still have the issue.
Any ideas ?
Thanks !
Try this:
pip install --user astropy[all]
and for the stsynphot package follow these steps: https://stsynphot.readthedocs.io/en/latest/

Categories

Resources