Trending questions in Python

0 votes
1 answer

How to insert a date into MySQL using Python?

Hi@akhtar, You can use the DateTime module to insert a date into ...READ MORE

Jul 15, 2020 in Python by MD
• 95,460 points
8,214 views
0 votes
0 answers

AttributeError: 'Index' object has no attribute 'get_values'

parameters = pd.read_csv(params_filename, sep="\t") free_parameters = parameters.columns.get_values().to_list() free_parameters = ...READ MORE

Sep 7, 2020 in Python by Swastik
• 120 points
5,944 views
0 votes
1 answer

Install a Python package into a different directory using pip?

Use: pip install --install-option="--prefix=$PREFIX_PATH" package_name You might also want ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,770 points
2,112 views
0 votes
1 answer

How to print colored text in Python?

This somewhat depends on what platform you ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,770 points
1,482 views
0 votes
1 answer

Error: Unhandled exception in thread started by Error in sys.excepthook:

I think the general idea of the ...READ MORE

Nov 2, 2020 in Python by Gitika
• 65,770 points
3,421 views
0 votes
1 answer

ModuleNotFoundError: No module named 'torch'

Hi@akhtar, It seems you don't have a torch ...READ MORE

Jun 24, 2020 in Python by MD
• 95,460 points
9,092 views
0 votes
1 answer

Error:Manager isn't accessible via model instances

Hello @kartik, The error caused when you try ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
6,729 views
0 votes
1 answer

Object of type ObjectId is not JSON serializable, how to send mongo object as json while return?

Hi, @There, Make sure that your MongoDB instance ...READ MORE

Oct 13, 2020 in Python by Gitika
• 65,770 points
4,205 views
0 votes
1 answer

Remove final character from string

Simple: st = "abcdefghij" st = st[:-1] There is ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
585 views
0 votes
2 answers

How to Import a module from a relative path?

If i understand your question correct then ...READ MORE

Dec 14, 2020 in Python by Tanja84DK

edited Dec 15, 2020 1,631 views
0 votes
2 answers

This kind of error throwing AttributeError: __enter__

I had recently found its solution and ...READ MORE

Jul 31, 2020 in Python by lokesh
7,907 views
0 votes
0 answers

joining two images reading from one folder

Hi, i am trying to generating joined ...READ MORE

Jan 3, 2021 in Python by shapna
• 120 points
660 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

Nov 12, 2018 in Python by Nymeria
• 3,560 points
34,451 views
0 votes
1 answer

ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

Hello @kartik, The render_to_response shortcut was deprecated in Django 2.0, and ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
8,576 views
0 votes
1 answer

Error in jarvis project (get url)

Hey, @Zodarlxx, Could you please post your error ...READ MORE

Dec 30, 2020 in Python by Gitika
• 65,770 points
776 views
0 votes
3 answers

Is there a simple way to delete a list element by value?

There are three ways in which you ...READ MORE

Dec 28, 2020 in Python by Thomas Walenta
733 views
0 votes
1 answer

Why is reading lines from stdin much slower in C++ than Python?

tl;dr: Because of different default settings in ...READ MORE

Dec 18, 2020 in Python by Nikita
1,239 views
0 votes
1 answer

How to change the width of form elements created with ModelForm in Django?

Hello @kartik, The easiest way for your use ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,840 points
7,368 views
0 votes
1 answer

How can I use Python to get the system hostname?

Hello @Kartik, Use socket and its gethostname() functionality. This will get the hostname of ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,840 points
1,641 views
0 votes
1 answer

How can I disable logging while running unit tests in Python Django?

Hello @kartik, Since you are in Django, you ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,840 points
8,901 views
0 votes
1 answer

How to get list from pandas DataFrame column headers?

You can get the values as a ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,770 points
978 views
0 votes
1 answer

Error:Expected view to be called with a URL keyword argument named “pk”

Hello @kartik, View functions are called with the ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
8,510 views
0 votes
1 answer

Python: “TypeError: Object type <class 'str'> cannot be passed to C code”

You have to pass byte string as ...READ MORE

Aug 20, 2019 in Python by Jishan
22,163 views
0 votes
2 answers

Recursive Pattern Using Python

n = int(input("please enter your no:")) k = ...READ MORE

Jun 28, 2020 in Python by Shaurya Thapliyal
• 340 points
7,372 views
0 votes
1 answer

How to divide one number to another multiple times, untill it will be about 0?

You can do something like this:  while num ...READ MORE

Nov 10, 2020 in Python by Gitika
• 65,770 points
2,776 views
0 votes
1 answer

Delete column from pandas DataFrame in python

As you've guessed, the right syntax is del ...READ MORE

Dec 20, 2020 in Python by Gitika
• 65,770 points
1,022 views
0 votes
1 answer

How to combine two or more querysets in a Django view?

Hello @kartik, Concatenating the querysets into a list ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,840 points
6,969 views
0 votes
1 answer

pip install mysql-python fails with EnvironmentError: mysql_config not found

It seems mysql_config is missing on your ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,770 points
1,579 views
0 votes
1 answer

invalid literal for int() with base 10 in python

Hello, You can try this simple code: def getSum(n): ...READ MORE

Nov 23, 2020 in Python by Niroj
• 82,840 points
2,085 views
0 votes
1 answer

Explain split() and join() functions in Python?

Hey, @Roshni, You can use split() function to split a ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,770 points
8,627 views
0 votes
1 answer

Hey Does anybody know how to fix the unexpected indent error?

Hello, @Aarohan, As the error message indicates, you ...READ MORE

Dec 28, 2020 in Python by Gitika
• 65,770 points
516 views
0 votes
1 answer

How to update Django session variable in javascript?

Hello @kartik, You can do this via Ajax. ...READ MORE

Jul 30, 2020 in Python by Niroj
• 82,840 points
6,984 views
0 votes
1 answer

Error:Traceback (most recent call last): File "< stdin >", line 1, in ImportError: cannot import name 'path'

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

Aug 5, 2020 in Python by Niroj
• 82,840 points
6,707 views
0 votes
1 answer

How to read a text file into a string variable and strip newlines?

You could use: with open('data.txt', 'r') as file: ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,770 points
654 views
+1 vote
2 answers

Python error "Python: can't assign to literal"

The way you're assigning variables is not ...READ MORE

Jun 17, 2019 in Python by Priya
15,751 views
0 votes
1 answer

For Professional window GUI develepoment which python lib/module/framework is best?

HI, @Ganesh, Tkinter is one of the most ...READ MORE

Dec 24, 2020 in Python by Gitika
• 65,770 points
603 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pymongo'

Hi@akhtar, It seems you don't have a Pymongo module ...READ MORE

Jun 26, 2020 in Python by MD
• 95,460 points
8,416 views
0 votes
1 answer

How do I build a website with referral link on Django?

simple solution.. import hashlib Refferal(Model): user ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,770 points
2,396 views
0 votes
0 answers

I can't get accurate value in dictionaries in django

Whenever I try to print the dictionaries ...READ MORE

Dec 25, 2020 in Python by Mohamed
• 170 points
549 views
0 votes
1 answer

How to get the SQL from a Django QuerySet?

Hello @kartik, Try this in your queryset: print my_queryset.query For ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,840 points
8,502 views
0 votes
1 answer

i am getting this error "TypeError: tuple indices must be integers or slices, not Database"

Hi, @Shabaj, Regarding your query, I hope this ...READ MORE

Dec 10, 2020 in Python by Gitika
• 65,770 points
1,163 views
0 votes
1 answer

Error:'QuerySet' object has no attribute 'remove'

Hello @kartik, You could do this: import itertools ids = ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,840 points
6,328 views
0 votes
1 answer

Error: wn = trtl.Screen() AttributeError: 'Turtle' object has no attribute 'Screen

Hi, @There, It requires a very simple hack ...READ MORE

Nov 3, 2020 in Python by Gitika
• 65,770 points
2,746 views
0 votes
1 answer

ImportError: cannot import name 'API_KEY' from 'forwarder'

The AWS package in PyPI is not AWS's official ...READ MORE

Nov 6, 2020 in Python by Gitika
• 65,770 points
2,598 views
0 votes
1 answer

How to find the index of an item in a list?

One thing that is really helpful in ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,770 points
1,429 views
0 votes
1 answer

please what does print_details do in python?

Hi, @There, The print() function prints the specified message to the ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,770 points
564 views
0 votes
1 answer

How to remove an element from a list by index?

Use del and specify the index of the element ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,770 points
771 views
0 votes
1 answer

ModuleNotFoundError: No module named 'urllib'

Hi@akhtar, You need to install urllib module in ...READ MORE

Jun 26, 2020 in Python by MD
• 95,460 points
8,337 views
0 votes
1 answer

How do you append to a file in Python?

with open("test.txt", "a") as myfile: ...READ MORE

Dec 20, 2020 in Python by Gitika
• 65,770 points
715 views
0 votes
1 answer

How can I remove a trailing newline?

Try the method rstrip() (see doc Python 2 and Python 3) >>> 'test ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,770 points
769 views