I got an error when importing matplotlib :
File "C:\Users\barre\PycharmProjects\dogs_cats\main.py", line 23, in <module>
import matplotlib.pyplot as plt
File "C:\Users\barre\PycharmProjects\dogs_cats\venv\lib\site-
packages\matplotlib\__init__.py",
line 105, in <module>
from packaging.version import parse as parse_version
ModuleNotFoundError: No module named 'packaging.version'
Seems that the problem comes from this line from the __init__.py
file of matplotlib :
line 105 : from packaging.version import parse as parse_version
I tried reinstalling matplotlib with following commands but still the same error :
pip uninstall matplotlib
python -m pip install --upgrade pip
pip install matplotlib
Thanks in advance.
My code :
import zipfile
import os
import cv2
import time
import random
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
import torchvision.transforms as T
from torchvision.utils import make_grid
from torchvision.models import resnet50
from sklearn.model_selection import train_test_split
from PIL import Image
import matplotlib.pyplot as plt
with zipfile.ZipFile("C:/Users/barre/PycharmProjects/dogs_cats/dogs-vs-cats/train.zip", "r") as z:
z.extractall(".")
with zipfile.ZipFile("C:/Users/barre/PycharmProjects/dogs_cats/dogs-vs-cats/test1.zip", "r") as z:
z.extractall(".")
CodePudding user response:
Please install packaging module by (pip Install packaging)