Most viewed questions in Python

0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,434 views
0 votes
1 answer

Python: is thread still running

The key is to start the thread ...READ MORE

Aug 5, 2019 in Python by SDeb
• 13,300 points
5,432 views
0 votes
1 answer

Measuring the distance between pixels on OpenCv with Python

Assuming input frames will have "close to ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
5,429 views
+1 vote
1 answer

How to read hdfs file using python?

subprocess.Popen(["hadoop", "fs", "-cat", "/path/to/myfile"], stdou ...READ MORE

Dec 7, 2018 in Python by Omkar
• 69,230 points
5,420 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

Apr 2, 2019 in Python by anonymous
5,419 views
0 votes
1 answer

How to download intext images with beautiful soup

Ohh... I got what you need. Try this: html_data ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,413 views
0 votes
1 answer

How to handle AssertionError in Python and find out which line or statement it occurred on?

Use the traceback module: import sys import traceback try: ...READ MORE

Dec 18, 2018 in Python by charlie_brown
• 7,720 points
5,412 views
0 votes
2 answers

Is it possible to launch python idle from a virtual environment?

Try running the following code. #!/usr/bin/env python """Simple script ...READ MORE

Jun 25, 2020 in Python by Sirajul
• 59,230 points
5,404 views
0 votes
1 answer

ValueError: too many values to unpack (expected 3)

Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
5,393 views
0 votes
1 answer

Avoid killing children when parent process is killed

I would recommend against your design as ...READ MORE

Sep 7, 2018 in Python by Priyaj
• 58,090 points
5,390 views
0 votes
1 answer

Changing variable name in Spyder

Right now there is no particular solution ...READ MORE

Apr 24, 2019 in Python by SDeb
• 13,300 points
5,384 views
0 votes
1 answer

How to avoid missing module docstring in pylint?

Either write your docs or use a ...READ MORE

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

Index of predicted wrong data in Keras, how to find it?

Simply, use: model.predict() pred = model.predict(x_test) indices = [i for ...READ MORE

Sep 28, 2018 in Python by Priyaj
• 58,090 points
5,365 views
0 votes
1 answer

How to add Django script to access model objects without using manage.py shell?

Hello @kartik, Use the following and you will be ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,880 points
5,358 views
0 votes
1 answer

Make a unix alias with python script

The scope of an alias command is the shell ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,352 views
0 votes
1 answer

How can I change the iteration variable inside a for loop in python?

Assume you have a list of lists: my_list ...READ MORE

Jun 10, 2019 in Python by Shubham Bansal
5,331 views
0 votes
1 answer

Error is '<' not supported between instances of str and int

your dis is obviously not 1.13, it's ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
5,327 views
0 votes
1 answer

how to read a JSON from a file?

You can use with statement with open('strings.json') as ...READ MORE

Oct 24, 2018 in Python by Priyaj
• 58,090 points
5,315 views
0 votes
1 answer

How to exit from Python without traceback?

Perhaps you're trying to catch all exceptions ...READ MORE

Jul 31, 2018 in Python by Priyaj
• 58,090 points
5,304 views
0 votes
1 answer

ImportError: No module named 'Cython'

Hi@akhtar, You need to install the Cython module ...READ MORE

Jul 13, 2020 in Python by MD
• 95,440 points
5,298 views
0 votes
1 answer

Python error "ValueError: size needs to be (int width, int height)" while using pygame.Surface

pygame.Surface takes in integer values for building ...READ MORE

Jun 19, 2019 in Python by Varsha
5,282 views
0 votes
1 answer

How to install packages using pip according to the requirements.txt file from a local directory?

This works for me: $ pip install -r ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,910 points
5,275 views
0 votes
1 answer

Python error "IndexError: Cannot choose from an empty sequence"

Hi @Isha, According to your error  File ...READ MORE

Jul 5, 2019 in Python by Patric
5,271 views
0 votes
1 answer

How do I print this list vertically?

You can try the following code: myList = ...READ MORE

Apr 5, 2019 in Python by SDeb
• 13,300 points
5,250 views
0 votes
1 answer

How to write to CSV line by line in python

The simple way of doing this will ...READ MORE

Nov 15, 2018 in Python by findingbugs
• 3,260 points
5,236 views
0 votes
1 answer

String is immutable data type. String.replace() So why there is command for string to replace the values....??

Hey, @Nelson, replace() actually returns a *copy* of ...READ MORE

Mar 30, 2020 in Python by Gitika
• 65,910 points
5,221 views
0 votes
1 answer

Difference between ElementTree and Minidom

Python allows parsing these XML documents using ...READ MORE

Jul 22, 2019 in Python by Wajiha
• 1,950 points
5,214 views
0 votes
1 answer

Error:Can't connect to local MySQL server through socket '/tmp/mysql.sock

Hello @kartik, Try the code below: sudo /usr/local/mysql/support-files/mysql.server start ...READ MORE

Jun 24, 2020 in Python by Niroj
• 82,880 points
5,207 views
0 votes
1 answer

How to download intext images with beautiful soup

Try this: html_data = """ <td colspan="3"><b>"Assemble under ...READ MORE

Sep 10, 2018 in Python by Priyaj
• 58,090 points
5,207 views
0 votes
1 answer

How can I generating file to download with Django?

Hello @kartik, To trigger a download you need ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
5,198 views
0 votes
1 answer

SciPy Create 2D Polygon Mask

You can try the following code: import numpy from ...READ MORE

Apr 22, 2019 in Python by SDeb
• 13,300 points
5,194 views
0 votes
1 answer

How to add a new Python interpreter in PyCharm?

Refer to the below screenshots: Then set a ...READ MORE

May 30, 2019 in Python by Shabnam
• 930 points
5,180 views
0 votes
1 answer

How to add integer to python array?

You have defined a numpy array but ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
5,162 views
+3 votes
2 answers

Compiled vs Interpreted Languages

Compiled languages are written in a code ...READ MORE

Dec 3, 2018 in Python by allenvarna
• 540 points
5,157 views
0 votes
1 answer

How to pass django rest framework response to html?

Hello @kartik, You need to use an @api_view decorator ...READ MORE

Jun 25, 2020 in Python by Niroj
• 82,880 points
5,152 views
+1 vote
2 answers

Speech (audio file, wav) to Text - getting timed out

I think the error you are getting ...READ MORE

Nov 27, 2018 in Python by Omkar
• 69,230 points
5,151 views
0 votes
1 answer

How to save a Pandas Dataframe to a pickle file?

Hi@akhtar, Python pickle module is used for serializing ...READ MORE

Oct 18, 2020 in Python by MD
• 95,440 points
5,149 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,115 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,099 views
0 votes
1 answer

Permission denied for .pyc file

Did you run the python script as ...READ MORE

Feb 7, 2019 in Python by Omkar
• 69,230 points
5,096 views
0 votes
1 answer

Error executing Jupyter command 'notebook': [Errno 2] No such file or directory

Hi@akhtar, I think there is a problem with ...READ MORE

Jun 25, 2020 in Python by MD
• 95,440 points
5,084 views
0 votes
1 answer

How can modify request.data in django REST framework?

Hello @kartik, Generally request in drf views is rest_framework.request.Request instance. Following to ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
5,083 views
0 votes
1 answer

How to dynamically compose an OR query filter in Django?

Hello @kartik, You could chain your queries as ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
5,072 views
0 votes
1 answer

Error saying "ValueError: Invalid file object: <_io.BufferedReader name=9>"

Once you've executed the following command, your ...READ MORE

May 28, 2019 in Python by Tamanna
5,070 views
0 votes
1 answer

How can I get dict from sqlite query?

Hii, Even using the sqlite3.Row class-- you still ...READ MORE

Apr 30, 2020 in Python by Niroj
• 82,880 points
5,066 views
0 votes
0 answers

TypeError: descriptor 'strftime' requires a 'datetime.date' object but received a 'str'

def dt_to_str(date, fma='%Y-%m-%d'):     """     Converts a datetime object to ...READ MORE

Mar 4, 2020 in Python by anonymous
• 120 points

recategorized Mar 4, 2020 by Gitika 5,060 views
0 votes
1 answer

Error: Catch a thread's exception in the caller thread in Python

The problem is that thread_obj.start() returns immediately. The child ...READ MORE

Nov 2, 2020 in Python by Gitika
• 65,910 points
5,057 views
0 votes
1 answer

Python and pip, list all versions of a package that's available?

The script at Pastebin does work. However, ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
5,044 views
0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

Apr 6, 2020 in Python by Gitika
• 65,910 points
5,027 views
0 votes
0 answers

utf-8' codec can't decode byte 0xa0 in position 10: invalid start byte

my code import wordcloud import numpy as np from matplotlib ...READ MORE

Mar 29, 2020 in Python by anonymous
• 120 points
5,024 views