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,491 views
+2 votes
6 answers

Slicing in Python

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

Oct 18, 2018 in Python by abc
1,156 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,082 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,659 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
748 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,922 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,481 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,621 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,357 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,286 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
971 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
369 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,714 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,037 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
628 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,811 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,816 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,087 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,106 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,562 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,281 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,762 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,116 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,067 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,400 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,966 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
923 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
565 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,278 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,061 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,500 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,009 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,751 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,368 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,651 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,017 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,897 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,375 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
881 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,914 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,229 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,241 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,011 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,457 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 5,989 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,083 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,738 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,147 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,016 views