Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ModuleNotFoundError: No module named 'Prueba3'
Para verificar conexion a una base de datos de Maria DB intento ejecutar en la Terminal de Visual Studio Code el archivo pruebadb.py que se encuentra en la carpeta con nombre Prueba3 (carpeta creada por defecto en la creacion del proyecto y que lleva el mismo nombre de este), pero me sale el error ModuleNotFoundError: No module named 'Prueba3' Codigo del archivo import pymysql from django.conf import settings conexion=pymysql.connect(DATABASES, 'hotelsys_1001') cursor = conexion.cursor() cursor.execute("INSERT INTO ro_rooms(number,id_ad_rooms_type,id_ad_rooms_status) VALUES(1020,1,1)") conexion.commit() print ("Registro almacenado exitosamente") conexion.close() Este es el mensaje de error en consola PS D:\Proyectos\Prueba3\prueba3> py pruebabd.py Traceback (most recent call last): File "D:\Proyectos\Prueba3\prueba3\pruebabd.py", line 1, in from Prueba3.settings import DATABASES ModuleNotFoundError: No module named 'Prueba3' Arbol del proyecto enter image description here -
how to filter field values based on other field values in Django
Let us consider my models.py as class ItemsInvoices(models.Model): RESERVED = 1 NOT_RESERVED = 2 ACCEPTED_BY_CUSTOMER = 3 PO_OR_DEPOSIT_RECEIVED = 4 DELIVERY_SET = 5 NOT_READY = 6 DELIVERED = 7 ORDER_STATUS = ( (RESERVED, 'Reserved'), (NOT_RESERVED, 'NOT Reserved'), (PO_OR_DEPOSIT_RECEIVED, 'Accepted by customer'), (PO_OR_DEPOSIT_RECEIVED, 'PO or deposit received'), (DELIVERY_SET, 'Delivery set'), (NOT_READY, 'Not ready'), (DELIVERED, 'Delivered'), ) invoice_number = models.IntegerField(blank=True, null=True) order_status = models.IntegerField(default=RESERVED, choices=ORDER_STATUS) class ItemsAddedInvoice(models.Model): item_invoice = models.ForeignKey(ItemsInvoices) class StockMovements(models.Model): item_added_invoice = models.ForeignKey(ItemsAddedInvoice, blank=True, null=True) sales_group_id = models.IntegerField(blank=True, null=True) Here based on my sales_group_id i need to filter the ItemsInvoices table items whose order_status is set to RESERVED.(Here we need to filter based on sales_group_id because for each sales_group_id we might have multiple item_added_invoice_id ) For example let us consider my database table for StockMovements as: item_added_invoice_id | sales_group_id 2206 | 1 2207 | 1 2208 | 2 2209 | 3 2210 | 4 2211 | 4 2212 | 4 2213 | 5 for ItemsAddedInvoice id | item_invoice_id 2206 | 1236 2207 | 1236 2208 | 1236 2209 | 1236 2210 | 1236 2211 | 1241 2212 | 1241 2213 | 1242 for ItemsInvoices id | order_status 1236 | 1 1241 | 2 1241 | 1 And finally in a … -
How to perform better filtering in django admin?
I have this filtering applied in my admin. But there are around 200 and much more unique id which is getting displayed on the right. How can I limit them? Is there are a better way to do this? @admin.register(Model) class Model(admin.ModelAdmin): list_filter = ['my_unique_id'] Screenshot of the admin -
Traceback (most recent call last): AttributeError: 'NoneType' object has no attribute 'Command'
When I run the code it shows me this error Traceback (most recent call last): File "E:\DJANGO-CRM-NEW\Django-CRM\manage.py", line 24, in <module> execute_from_command_line(sys.argv) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 400, in execute_from_command_line utility.execute() File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 244, in fetch_command klass = load_command_class(app_name, subcommand) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 38, in load_command_class return module.Command() AttributeError: 'NoneType' object has no attribute 'Command' PS E:\DJANGO-CRM-NEW\Django-CRM> py manage.py runserver Traceback (most recent call last): File "E:\DJANGO-CRM-NEW\Django-CRM\manage.py", line 24, in <module> execute_from_command_line(sys.argv) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 400, in execute_from_command_line utility.execute() File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 244, in fetch_command klass = load_command_class(app_name, subcommand) File "C:\Users\iamra\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 38, in load_command_class return module.Command() AttributeError: 'NoneType' object has no attribute 'Command' -
Django nested forms
I have trouble figuring out how to create nested forms. I have two models: Poll and Question (foreign key for Poll is inside Question model). I want it to be possible to add several questions for the poll dynamically inside one form. I've already tried making it work with inlineform_factory, but found troubles saving the form. Right now I have overcomplicated code that throws MultiValueDictError after saving the poll for the second time. I thought maybe there is some other way. Here's my code models.py class Question(models.Model): type_choices = ( ('text', 'Текстовый'), ('integer', 'Числовой'), ) type = models.CharField(verbose_name=u'Тип вопроса', choices=type_choices, max_length=70) text = models.CharField(verbose_name=u'Текст вопроса', max_length=255) poll = models.ForeignKey('Poll', on_delete=models.CASCADE, related_name='questions') class Poll(BaseFields): objects = models.Manager() published = PublishedManager() title = models.CharField(verbose_name=u'Заголовок', max_length=70) date_from = models.DateTimeField(u'Дата начала') date_to = models.DateTimeField(u'Дата окончания') status = models.IntegerField(choices=Status.choices, default=0) def status_name(self): return dict(Status.choices).get(self.status) def update_url(self): return reverse('poll_update', args=(self.id, )) forms.py QuestionInlineFormSet = inlineformset_factory(Poll, Question, extra=1, can_delete=False, fields=('type', 'text', 'poll'), widgets={ 'type': w.Select(attrs={'class': 'form-control'}), 'text': w.TextInput(attrs={'class': 'form-control'}), }) class PollForm(CommonForm): class Meta(CommonForm.Meta): model = Poll views.py class Create(BaseCreateView): template_name = 'back/poll/poll.html' page_title = 'Создание опроса' model = Poll form_class = PollForm def form_valid(self, form): result = super(Create, self).form_valid(form) questions_formset = QuestionInlineFormSet(data=form.data, instance=self.object, prefix='questions_formset') if questions_formset.is_valid(): … -
I'm trying to do remember me feature at login page using django built-in auth view
from django.contrib.auth.views import LoginView from django.contrib.auth.forms import AuthenticationForm class MyLoginView(LoginView): def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs['request'] = self.request # print(self.get_initial(),'--------1') return kwargs def get_form_class(self): if self.request.POST: if self.request.POST.get('remember'): self.request.session['usernameS'] = self.request.POST['username'] self.request.session['passwordS'] = self.request.POST['password'] self.request.session['remember'] = True self.initial = { 'username':self.request.session.get('usernameS'), 'password':self.request.session.get('passwordS'), 'remember':self.request.session.get('remember') } print(self.initial) return self.authentication_form or self.form_class But whenever I logged out it's not showing initial values### -
Django JWT authentication doesn't work in browser?
I'm trying to do django authentication with JWT in my django+react app. I'm using part 1 of this tutorial: https://hackernoon.com/110percent-complete-jwt-authentication-with-django-and-react-2020-iejq34ta Everything works fine when I use cURL in terminal to get access to my API, but when I run server in my browser I'm still getting What does this behaviour mean? -
Creating annotation based on subquery with parameters
I have two models in my app, Event and Registration, with the most important fields below: class Event(models.Model): ... capacity = models.IntegerField() ... class Registration(models.Model): timestamp = models.DateTimeField(auto_now_add=True) event = models.ForeignKey(Event, on_delete=models.CASCADE) uses_bus = models.BooleanField(default=False) is_vegan = models.BooleanField(default=False) user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, default=None) Now, in either a field or in the admin, I am trying to get the number of registrations where the user has marked uses_bus and the number of registrations where the user has marked is_vegan. This could be something like this: class EventAdmin(admin.ModelAdmin): list_display = ('title', 'date', 'nr_registrations', 'nr_bus') inlines = [RegistrationInline] def get_queryset(self, request): queryset = super(EventAdmin, self).get_queryset(request) return queryset.annotate( nr_registrations = Count('registration'), nr_bus = Count('registration', filter=Q(registration__uses_bus=True)), nr_vegan = Count('registration', filter=Q(registration__is_vegan=True)), ) def nr_registrations(self, obj): return obj.nr_registrations def nr_bus(self, obj): return obj.nr_bus def nr_vegan(self, obj): return obj.nr_vegan but this obviously finds the total number of bus registrations, not the number of bus registrations for the ones that can actually attend the event because of the capacity constraints. In SQL I would solve this like this: SELECT SUM(uses_bus) FROM (SELECT CAST(uses_bus AS INTEGER) FROM events_registration WHERE event_id = *event id* ORDER BY id LIMIT *capacity*) AS a but I can't do this, because even if I … -
how to stop django autoreload without comman line argumer "--noreload"
I have developer a django app with the apscheduler and the scheduler runs twice whenever I don't use the "--noreload" command line argument with it. It was fine until I had it running on my local machine but after running it in the cpanel I don't understand how to stop the autoreloader since I can't enter a command line argument there. Please let me know how i can stop this from happening. -
I can't import JSONfield in Django==3.0
I was using Django==3.2.7 in my project, but I installed 3.0 due to some reason. But I can't import the JSONField from django.db.models. Here is the error message. from django.db.models import JSONField ImportError: cannot import name 'JSONField' from 'django.db.models' (/home/userstar713/workspace/weini/hotel_booking/mobytrip-hotelbeds/hotel_booking_backend/venv/lib/python3.8/site-packages/django/db/models/__init__.py) Please give me a suggestion. Thank you. -
Docker ModuleNotFoundError: No module named 'boto3'
I'm trying to make a web app using django and in views.py file I added imort boto3 . it worked perfectly when i tried it without docker but now i get this error: ModuleNotFoundError: No module named 'boto3' so here is my dockerfile FROM python:3 ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY ./requirements.txt /app/requirements.txt RUN pip install -r requirements.txt RUN pip install boto3 -t . COPY . /app/ ADD . /app ENV PYTHONPATH /app CMD [ "python", "/app/greet/views.py" ] and this is my docker-compose.yml file version: '3' services: web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/app ports: - "8000:8000" -
How to send httponly cookie with axios?
I'm using a django backend, and a CRAO frontend. I saved the jwt refresh token as a httponly cookie: document.cookie = `refresh=${refresh_token}; SameSite=Strict; Path=/api/token/refresh; HttpOnly`; Then to refresh the access token, I'm sending an axios request: const response = await axios.post('/api/token/refresh/', { withCredentials: true }); But, in this case, the originally saved cookies don't get sent by axios. However, on removing the httponly attribute, the cookies do get sent, and everything works fine. -
How to connect a payment service to a Django/Flask registration process? [closed]
How do i connect a registration form which uses Django or flask with a payment service like PayPal? And what tools could be used instead to simplify the process in view of performance and security? -
How to use helios-client python module?
Now I want to use Python helios-client module. https://snyk.io/advisor/python/helios-client this is url. I am using Django as a backend. But I am not sure how to use this module. For example, what method should I use if I want to search similar songs. https://heliosmusic.io/api.html#operation/getSongsByReference here is their API document. Please give me your hands. Thanks. -
how to allow web file content update using django supervisor nginx and gunicorn
I am using django inside of ubuntu os and connected it to supervisor, nginx, gunicorn with following config supervisor [program:gunicorn] directory=/home/ubuntu/test_app/backend command=/home/ubuntu/test_app/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/test_app/backend/app.sock backend.wsgi:application autostart=true autorestart=true stderr_logfile=/var/log/gunicorn/gunicorn.err.log stdout_logfile=/var/log/gunicorn/gunicorn.out.log [group:guni] programs:gunicorn then i created a sym-link between sites-availabes with site-enabled nginx server { listen 80; server_name EC2Endpoint; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/test_app/backend/app.sock; } location /static { autoindex on; alias /home/ubuntu/test_app/backend/static; } } also, i enabled firewall with firewall sudo ufw allow 80 sudo ufw allow 22 sudo ufw enable now everything work fine except whenever i change a file in the django application, no matter how much i try to reload, restart nginx or supervisor, i cannot see the result of the changes applied. I read in a similar post that i must restart gunicorn but when i do sudo service gunicorn restart i get the error Failed to restart gunicorn.service: Unit gunicorn.service not found. Again from the same post i read that i must go in /etc/systemd/system then create a gunicorn.service file, which i did:` cd /etc/systemd/system sudo touch gunicorn.service then when i do : sudo systemctl enable gunicorn.service i get: Failed to enable unit: Unit file /etc/systemd/system/gunicorn.service is masked. to try to solve it: … -
I'm trying to display a single post in Django but I'm getting: Server Error(500)
I'm using Django to display my post models. When I try to display multiple posts, it works but a single post isn't working for me. I'm not really sure why. Here is what I did: views.py def post(request, pk): post = Post.object.get(id = pk) context = {'post': post} return render(request, 'base/post.html', context) urls.py urlpatterns = [ path('', views.home, name="home"), path('posts/', views.posts, name='posts'), path('post/<str:pk>/', views.post, name='post'),] post.html <h3>{{post.headline}}</h3> <h4>{{post.sub_headline}}</h4> <p>{{post.body|linebreaks}}</p> Edit: Adding my Post model class Post(models.Model): headline = models.CharField(max_length=200) sub_headline = models.CharField(max_length=200, null=True, blank=True) # thumbnail = body = models.TextField(null=True, blank=True) created = models.DateTimeField(auto_now_add=True) active = models.BooleanField(default=False) featured = models.BooleanField(default=False) tags = models.ManyToManyField(Tag, null=True) # slug def __str__(self): return self.headline -
AttributeError: 'list' object has no attribute 'split' Django Haystack Solr
I'm working with django-haystack to use solr. However, I got "AttributeError: 'list' object has no attribute 'split'" when I search something at "127.0.0.1:8000/blog/search" how to solve this problem? terminal says that at blog/views.py "total_results = results.count()" error occured. blog/views.py from django.shortcuts import render, get_object_or_404 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.mail import send_mail from django.views.generic import ListView from django.db.models import Count from taggit.models import Tag from .models import Post, Comment from .forms import EmailPostForm, CommentForm, SearchForm from haystack.query import SearchQuerySet def post_search(request): form = SearchForm() if 'query' in request.GET: form = SearchForm(request.GET) if form.is_valid(): cd = form.cleaned_data results = SearchQuerySet().models(Post).filter(content=cd['query']).load_all() print(results) # count total results total_results = results.count() return render(request, 'blog/post/search.html', {'form': form, 'cd': cd, 'results': results, 'total_results': total_results}) return render(request, 'blog/post/search.html', {'form': form}) blog/forms.py from django import forms from .models import Comment class EmailPostForm(forms.Form): name = forms.CharField(max_length=25) email = forms.EmailField() to = forms.EmailField() comments = forms.CharField(required=False, widget=forms.Textarea) class CommentForm(forms.ModelForm): class Meta: model = Comment fields = ('name', 'email', 'body') class SearchForm(forms.Form): query = forms.CharField() blog/templates/blog/post/search.html {% extends "blog/base.html" %} {% block title %}Search{% endblock %} {% block content %} {% if "query" in request.GET %} <h1>Posts containing "{{ cd.query }}"</h1> <h3>Found {{ total_results }} result{{ total_results|pluralize}}</h3> {% for … -
Django Oscar Promotions not rendering promoted pages pages to home page
I read all the posts I could find online and tried all the possible solutions, earlier I was getting errors due to page_url not added to form meta class but after fixing that everything seems to be working fine, now the problem is that whenever I create a promotion and submit it to a URL let's say / which is home of I go back to site and refresh the home page I nothing shows up apart from the default home page. What am I getting wrong pls? What I also noticed is that when a promotion is submitted the layout is suppose to change to layout_2_col.html and it does not I have tried every single thing -
In Django, whitenoise do not show static files?
I am trying to show static files while debug=false.I am using whitenoise library but still website don't show the static files and media files. My settings.py file like this: MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' STATIC_URL = '/static/' STATIC_DIR = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ] MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/' -
How Can I sum the Result of a Django Date Range Result in Views
I want to add all the amount field during a date range query search. I have an Income Model with date and amount fields among others. And any time a user select between two dates, I want the amount fields of the query results added as total. Here is what I have tried: def SearchIncomeRange(request): listIncome = Income.objects.all() searchForm = IncomeSearchForm(request.POST or None) if request.method == 'POST': listIncome = Income.objects.filter( description__icontains=searchForm['description'].value(), date__range=[ searchForm['start_date'].value(), searchForm['end_date'].value() ] ) else: searchForm = IncomeSearchForm() context = { 'searchForm':searchForm, } return render(request, 'cashier/search_income_range.html', context) I am able to get the correct search result but getting the total I don't know how to use the SUM in the above query. So Someone should please help me out. Thanks -
How to deploy a Python script working under Django app?
I developed a Django app and created a script that runs through it. This script does everything I need just by running it with python3 manage.py runscript script_name I'd like now to deploy it outside of my local environment in order to run it automatically (without me manually launching it). First, I thought about deploying it on AWS Lambda but I have a hard time to figure out if that fit my needs and if I can run this sort of script out there. I have only few requirements, it needs to be on an UK server and have a database. Also this script is basically looping by itself once it's runned. Any idea or help with AWS for what I'm trying to achieve would be welcomed. Thank you. -
How to hide image from Django template?
I'm trying to make a blog website. On the all post page, it renders all the posts from the database. But not all post has its feature image. So, I'm trying to hide those image sections that don't have any featured images. Here is blog/model.py class Article(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published'), ) author = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.SET_NULL) title = models.CharField(max_length=200) slug = AutoSlugField(populate_from='title', unique=True, null=False, db_index=True) excerpt = models.CharField(max_length=60) featured_image = models.ImageField(upload_to="posts", null=True, blank=True, default="default.jpg") content = FroalaField() created = models.DateTimeField(auto_now_add=True) last_update = models.DateTimeField(auto_now=True) publish = models.DateTimeField(default=timezone.now) status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft') Here is blog/view.py # display all blog posts def posts(request): all_posts = Article.published.all() context = {'all_posts': all_posts} return render(request, 'blog/posts.html', context) # Single post def single_post(request, slug): post = Article.objects.get(slug=slug) context = { 'post': post, } return render(request, 'blog/single-post.html', context) Here is blog/url.py urlpatterns = [ path('', views.posts, name="posts"), path('post/<slug:slug>/', views.single_post, name="single-post"), ] Here is post.html {% for post in all_posts %} <li class="bg-white px-4 py-6 shadow sm:p-6 sm:rounded-lg"> <article aria-labelledby="question-title-81614"> <a href="{{ post.get_absolute_url }}"> <!-- author details & option menus --> <div class="flex space-x-3"> <div class="flex-shrink-0"> <!-- author image --> <img class="h-10 w-10 rounded-full" src="{{ post.author.profile.avatar.url }}" alt="" /> </div> <!-- author name … -
Getting {"detail":"Method \"GET\" not allowed."} for user registration
I know this was asked a thousand times already but none of them solved my issue. I am trying to use Rest in my view. I get the error in title when I send a post request to the accounts/register/ url. models.py: from django.contrib.auth.models import AbstractUser from django.db import models from .validators import phone_validator class User(AbstractUser): class Gender(models.TextChoices): MALE = 'M', 'Male' FEMALE = 'F', 'Female' UNSET = 'MF', 'Unset' phone = models.CharField(max_length=15, validators=[phone_validator], blank=True) address = models.TextField(blank=True) gender = models.CharField(max_length=2, choices=Gender.choices, default=Gender.UNSET) age = models.PositiveSmallIntegerField(blank=True, null=True) description = models.TextField(blank=True) @property def is_benefactor(self): return hasattr(self, 'benefactor') @property def is_charity(self): return hasattr(self, 'charity') serializers.py: class Meta: model = User fields = [ "username", "password", "address", "gender", "phone", "age", "description", "first_name", "last_name", "email", ] def create(self, validated_data): user = User(**validated_data) user.set_password(validated_data['password']) user.save() return user urls.py (the one in the app. its included in the root urls.py with the 'accounts/' url) from django.urls import path from rest_framework.authtoken.views import obtain_auth_token from .views import UserRegistration, LogoutAPIView urlpatterns = [ path('login/', obtain_auth_token), path('logout/', LogoutAPIView.as_view()), path('register/', UserRegistration.as_view()), ] views.py: from rest_framework import status from rest_framework.mixins import CreateModelMixin from rest_framework.permissions import IsAuthenticated, AllowAny from rest_framework.response import Response from rest_framework.views import APIView from .serializers import UserSerializer from .models import … -
How can I implement a location picker for user's searches?
I'm working on an internationalized website in Django where users need to specify their location and where users also serach things by location. I have several possible solutions: City autocomplete. Users just have to type a city and an autocomplete list will suggest complete triplets (city-state-country) to choose from. Using 3 levels dependent drop-down lists where the user first choose a country, then he picks a state and finally a city. Using a map picker where user have to click the location he want and the corresponding triplet (city-state-country) will complete. Solution 1 is very elegant. But it has several issues. The multilanguage nature of the website forces to translate any suggestion and it is not possible to translate partial inputs. A Mexican who is likely to type "Ciudad de México" with a tilded e, would not find it because the name of the city is "Mexico City" in the database. And users always risk to not find the appropriate suggestion or pick the wrong one. I would rather drop this solution even if I already have built it. Solution 2 would be very functional. But it is a little outdated and also it would complicate the user experience, expecially … -
when creating todoapp AttributeError: module 'typing' has no attribute 'NoReturn' when installing django
when entering virtual environment and trying to install django error occurs: Traceback (most recent call last): File "c:\users\user\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\user\appdata\local\programs\python\python36\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Users\user\Envs\test\Scripts\pip.exe_main.py", line 4, in File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\cli\main.py", line 9, in from pip._internal.cli.autocompletion import autocomplete File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\cli\autocompletion.py", line 10, in from pip._internal.cli.main_parser import create_main_parser File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\cli\main_parser.py", line 8, in from pip._internal.cli import cmdoptions File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\cli\cmdoptions.py", line 23, in from pip._internal.cli.parser import ConfigOptionParser File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\cli\parser.py", line 12, in from pip._internal.configuration import Configuration, ConfigurationError File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\configuration.py", line 27, in from pip.internal.utils.misc import ensure_dir, enum File "C:\Users\user\Envs\test\lib\site-packages\pip_internal\utils\misc.py", line 38, in from pip.vendor.tenacity import retry, stop_after_delay, wait_fixed File "C:\Users\user\Envs\test\lib\site-packages\pip_vendor\tenacity_init.py", line 186, in class RetryError(Exception): File "C:\Users\user\Envs\test\lib\site-packages\pip_vendor\tenacity_init.py", line 193, in RetryError def reraise(self) -> t.NoReturn: AttributeError: module 'typing' has no attribute 'NoReturn'