ImportError: No module named '_tkinter'? - python

My imports :
from pydub import AudioSegment
import matplotlib.pyplot as plt
import numpy as np
import wave
import sys
why am i getting that error while i'm clearly not importing tkinter and how to fix it

One of your imported packages requires tkinter as a dependency, so you need to install it.
# if you are using Anaconda
conda install tk
# if you are using Ubuntu
sudo apt-get install python3-tk

Related

issue accessing clip-vit-large-patch14 in order to load HF model (python)

I am trying to run some code to setup and load a model, keep getting this error:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/x/.cache/huggingface/hub/models--openai--clip-vit-large-patch14/refs/main'
tried to create it directly in my terminal (mac m1) and now I am getting this error instead (IsADirectoryError: [Errno 21] Is a directory: '/Users/x/.cache/huggingface/hub/models--openai--clip-vit-large-patch14/refs/main'), not sure what I am supposed to do to avoid this error.
I have these loaded, gives no error and sd-v1-4.ckpt and sd-clip-vit-l14-img-embed_ema_only.ckpt under the models. Please let me know if I need to provide any additional information, I am new to this and not sure if I missed anything important! Thank you!
!pip3 install omegaconf
!pip3 install torch torchvision
!pip3 install pytorch-lightning
!pip3 install einops
!pip3 install lightning-bolts
!pip3 install --ignore-installed PyYAML #referenced from https://stackoverflow.com/questions/62402718/error-cannot-uninstall-pyyaml-resolved-method
!pip3 install taming-transformers-rom1504
!pip3 install git+https://github.com/openai/CLIP.git
!pip3 install transformers
!pip3 install kornia
from omegaconf import OmegaConf
import torch
from PIL import Image
from torchvision import transforms
import os
from tqdm import tqdm
from einops import rearrange
import numpy as np
from pathlib import Path
import matplotlib.pyplot as plt
from huggingface_hub import notebook_login
from transformers import CLIPProcessor, CLIPModel
from ldm.util import instantiate_from_config
from ldm.models.diffusion.ddim import DDIMSampler
from ldm.models.diffusion.plms import PLMSSampler
from ldm.invoke.devices import choose_torch_device
tried to create it directly in my terminal (mac m1) and now I am getting this error instead (IsADirectoryError: [Errno 21] Is a directory: '/Users/x/.cache/huggingface/hub/models--openai--clip-vit-large-patch14/refs/main'), not sure what I am supposed to do to avoid this error.

Can't import VecFrameStackFrame from Stable-baselines3 - importing problem

I have a problem when importing some dependencies from stable baselines 3 library, I installed it with this command
pip install stable-baselines3[extra]
But When I import my dependencies
import gym
from stable_baselines3 import A2C
from stable_baselines3.common.vec_env import VecFrameStackFrame
from stable_baselines3.common.evaluation import evaluate_policy
from stable_baselines3.common.env_util import make_atari_env
import os
I face this error
ImportError: cannot import name 'VecFrameStackFrame' from 'stable_baselines3.common.vec_env' (C:\Users\User\anaconda3\envs\rl_learning\lib\site-packages\stable_baselines3\common\vec_env\__init__.py)
Any advice?
I knew that stable baselines new version has changed the name from
from stable_baselines3.common.vec_env import VecFrameStackFrame
To
from stable_baselines3.common.vec_env import vec_frame_stack
and it worked for me

Cannot import umap: cannot import name 'structref' from 'numba.experimental'

I tried to import umap in my jupyter notebook but had the following error:
ImportError: cannot import name 'structref' from 'numba.experimental' (C:\Users\name\Anaconda3\lib\site-packages\numba\experimental\__init__.py)
I tried to update conda but doesn't work. What can I do ?
The numba.experimental subpackage was added in version 0.51.0. You can check your version of number using:
import numba
numba.__version__
If it is less then 0.51.0, you will need to install a newer version.
conda install numba=0.51.*

ImportError: cannot import name 'styles' from 'matplotlib'

The issue is in the title:
ImportError: cannot import name 'styles' from 'matplotlib'
I have tried the recommended answers, I have used
sudo pip install --upgrade matplotlib
and
pip install --user --upgrade matplotlib
and still have the same error as before.
Code:
import tkinter as tk
from tkinter import ttk
import matplotlib
from matplotlib import styles
LARGE_FONT = ("Verdana", 12)
error:
ImportError: cannot import name 'styles' from 'matplotlib'
(/Users/myname/opt/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py)
I have tried this with a few python versions in vs code (3.6.6, 3.7.6, 3.8.1) and Anaconda Spyder (which I believe is 3.7.x but I'm not sure which) and get the same error.
Any ideas or is Matplotlib styles not useable anymore?
Do you mean 'style' instead of 'styles'?
from matplotlib import style

ModuleNotFoundError: No module named 'utils.datasets'

I am using Python 3.6.8 on Windows 10
I installed tensorflow, keras, and utils using pip.
pip install tensorflow and it installs the version 2.0.0
pip install keras and it installs the version 2.3.1
pip install utils but it does not show what version I have installed.
This is my header:
from keras.preprocessing import image
from PIL import Image
from keras.models import model_from_json, load_model
import numpy as np
import cv2
from datetime import datetime
import os
import random
import string
from utils.datasets import get_labels
from utils.inference import apply_offsets
from utils.inference import load_detection_model
from utils.preprocessor import preprocess_input
This is my error:
from utils.datasets import get_labels
ModuleNotFoundError: No module named 'utils.datasets'
Why am I getting this error? And how to fix it? BTW The code was written by a previous programmer and I need to modify it. But I can't even run it. not so good in python tho. i'm just getting started to it.
All my google search are all purple but I can't seem to find any solutions.
EDIT
The suggested answer (ImportError: No module named datasets) does not satisfy my needs. I am having trouble on utils module. because when I comment out the line from utils.datasets import get_labels
The error is on the next line:
ModuleNotFoundError: No module named 'utils.inference'
The utils model what the code your provided want to import is the part of the oarriaga/face_classification project.
The pip installed utils modul is quite different package, so you should not have installed via pip. Your code try to import moduls from this package, but it obviously has no such moduls. That is why the error messages.
So what you have to do is pip uninstall utils and then if your project directory structure is complete, the above code will import the face_classification package's moduls.

Categories