Most voted questions in Python

+2 votes
6 answers

How can I change directory or "cd" in Python?

Context Manager: cd import os class cd:     """Context manager for ...READ MORE

Oct 18, 2018 in Python by Nabarupa
27,568 views
+2 votes
6 answers

Slicing in Python

Index: ------------> ...READ MORE

Oct 18, 2018 in Python by abc
1,177 views
+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

Apr 10, 2018 in Python by charlie_brown
• 7,720 points
1,092 views
+2 votes
2 answers

How can I plot a k-dsitance graph using python?

Hi there, instead of sklearn you could ...READ MORE

Apr 10, 2018 in Python by charlie_brown
• 7,720 points
4,669 views
+2 votes
2 answers

How to use BeatifulSoup for webscraping?

your programme is fine until you start ...READ MORE

Apr 4, 2018 in Python by charlie_brown
• 7,720 points
757 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

Apr 4, 2018 in Python by charlie_brown
• 7,720 points
12,959 views
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

Apr 3, 2018 in Python by charlie_brown
• 7,720 points
4,495 views
+2 votes
4 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

Aug 13, 2018 in Python by bug_seeker
• 15,520 points
119,825 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
5,428 views
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
4,318 views
+2 votes
2 answers

How can I create a new file in Python?

You can try the below code which ...READ MORE

Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
983 views
+1 vote
1 answer

Unzipping files in Python

Use this code: import zipfile with zipfile.ZipFile(path_to_zip_file, 'r') as ...READ MORE

Apr 25, 2022 in Python by narikkadan
• 63,420 points
376 views
+1 vote
1 answer

tensorflow is installed but theres an error while importing

Hi@Christlan, This problem is related to version. Follow ...READ MORE

Dec 22, 2020 in Python by MD
• 95,440 points
12,757 views
+1 vote
1 answer

Can anyone help me with this error: TypeError: list indices must be integers or slices, not str

Hi, @Varshap  It’s a TypeError, which tells us ...READ MORE

Nov 5, 2020 in Python by anonymous
• 65,910 points
2,048 views
+1 vote
1 answer

How to change the order of DataFrame columns in pandas?

Hi@akhtar, You can rearrange a DataFrame object by ...READ MORE

Oct 20, 2020 in Python by MD
• 95,440 points
635 views
+1 vote
1 answer

How to get the currently logged in user's user id in Django?

Hello @kartik, First make sure you have SessionMiddleware and AuthenticationMiddleware middlewares added ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
35,897 views
+1 vote
1 answer

Web Scraping with Python:-> ModuleNotFoundError: no module named 'selenium'

Hello @shamsher, First try to check what version ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
3,838 views
+1 vote
1 answer

WindowsError: [Error 126] The specified module could not be found.

Hi@akhtar, You can download the shapely module in ...READ MORE

Jul 13, 2020 in Python by MD
• 95,440 points
1,093 views
+1 vote
3 answers

While using pyttsx 3 , I am having the following ERROR, i have installed pypiwin32

Try this: pip uninstall pyttsx3 Then: pip install pyttsx3==2.71 READ MORE

Aug 12, 2020 in Python by Eghosa
7,141 views
+1 vote
1 answer

How do I return JSON without using a template in Django?

Hello @kartik, In the case of the JSON ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,880 points
4,568 views
+1 vote
1 answer

Error:<map object at 0x7fa3435f3048> is not JSON serializable

Hello @kartik, map() in Python 3 is a generator ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,880 points
2,286 views
+1 vote
1 answer

Error:Unable to import path from django.urls

Hello @kartik, You need Django version 2 pip install ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
10,795 views
+1 vote
1 answer

How to validate a field on update in DRF?

Hello @kartik, You can definitely do this using ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
9,130 views
+1 vote
1 answer

How to create a file and save it to a model's FileField in Django?

Hello @kartik, Basically, a field declared as a FileField, ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
14,097 views
+1 vote
1 answer

Error:__init__() got an unexpected keyword argument 'user'

Hello @kartik, You can't do LivingRoom.objects.create(user=instance) because you have an __init__ method ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
16,416 views
+1 vote
1 answer

How to save image/file through django shell?

Hii @kartik, You will end up with the ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,880 points
3,980 views
+1 vote
1 answer

How to create a model dynamically just for testing in djanjo?

Hello @kartik, The basic idea is, make your tests an ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,880 points
938 views
+1 vote
1 answer

How to get the home directory using ‘~’ in Python?

Hello, @Roshni, You need to import the os module, ...READ MORE

Jun 26, 2020 in Python by Gitika
• 65,910 points
574 views
+1 vote
1 answer

How can I build multiple submit buttons django form?

Hiii @kartik, You can use self.data in the clean_email method to access ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
2,295 views
+1 vote
1 answer

How do I create a slug in Django?

Hello @kartik, You will need to use the ...READ MORE

Jun 26, 2020 in Python by Niroj
• 82,880 points
1,071 views
+1 vote
1 answer

'utf-8' codec can't decode byte 0xa9 in position 12527: invalid start byte

Hello, You can always safely read in binary ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
13,531 views
+1 vote
2 answers

ModuleNotFoundError: No module named 'selenium'

i fix the problem after installing go ...READ MORE

Nov 18, 2020 in Python by ahmed
24,038 views
+1 vote
2 answers

What is the difference between .py and .pyc files in Python?

Hi, @Roshni, You can follow a few steps ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,910 points
32,834 views
+1 vote
1 answer

How to install django in anaconda prompt?

Here are the steps that you can ...READ MORE

Jun 23, 2020 in Python by Sirajul
• 59,230 points
6,379 views
+1 vote
2 answers

Error:Django gives Bad Request (400) when DEBUG = False

Tried this and it resolved all my ...READ MORE

Sep 25, 2020 in Python by Agaba
5,673 views
+1 vote
1 answer

module 'numpy' has no attribute 'unit8'

Hi@akhtar, You have used unit8 in your code. ...READ MORE

Jun 23, 2020 in Python by MD
• 95,440 points
15,043 views
+1 vote
1 answer

Error:Getting Site Matching Query Does Not Exist Error after creating django admin

Hello @kartik, The Site object for your Django project is ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
11,924 views
+1 vote
1 answer

ImportError: DLL load failed: The specified module could not be found.

Hi@akhtar, You may get this error if you ...READ MORE

Jun 22, 2020 in Python by MD
• 95,440 points
9,389 views
+1 vote
1 answer

Error: current transaction is aborted, commands ignored until end of transaction block?

Hello @kartik, To get rid of the error, roll ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
887 views
+1 vote
1 answer

How to convert a PIL Image into a numpy array?

Hello @kartik, You just need to convert your ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
3,937 views
+1 vote
1 answer

Error:Pandas read_csv low_memory and dtype options

Hello @kartik, Try this: dashboard_df = pd.read_csv(p_file, sep=',', error_bad_lines=False, ...READ MORE

Jun 22, 2020 in Python by Niroj
• 82,880 points
14,275 views
+1 vote
1 answer

How to save graph using matplotlib library?

Hi@akhtar, You can find one function called savefig ...READ MORE

May 21, 2020 in Python by MD
• 95,440 points
1,248 views
+1 vote
1 answer

understand this error:AttributeError: 'Turtle' object has no attribute 'Listen'. Any ideas?

Hey, @Mohammed, You are getting this error because ...READ MORE

May 20, 2020 in Python by Gitika
• 65,910 points
5,038 views
+1 vote
0 answers

TypeError: unsupported operand type(s) for /: 'list' and 'list'

This is my part of code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 2,472 views
+1 vote
0 answers

ValueError: operands could not be broadcast together with shapes (3,) (1000,)

This is the part of my code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 6,001 views
+1 vote
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi, You created two empty list. And in ...READ MORE

May 17, 2020 in Python by MD
• 95,440 points
5,094 views
+1 vote
1 answer

'numpy.ndarray' object has no attribute 'append'

Hi@Noman, You created two empty list. And in ...READ MORE

May 17, 2020 in Python by MD
• 95,440 points
7,760 views
+1 vote
1 answer

ImportError: cannot import name 'appdirs'

Hi@akhtar, I think you missed some module to ...READ MORE

May 5, 2020 in Python by MD
• 95,440 points
3,177 views
+1 vote
1 answer

Want to know how to write paragraph on image using pillow python?

Hi, @Shantanu, You can make use of the ...READ MORE

Apr 14, 2020 in Python by Gitika
• 65,910 points
2,025 views