Questions tagged [python]

Python is a multi-paradigm, dynamically typed, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax. Two similar but incompatible versions of Python are commonly in use, Python 2.7 and 3.x. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant or library (e.g. Jython, PyPy, Pandas, Numpy), please include it in the tags.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

I want to learn how to use Python to recognize certain images in a specific portion of my screen

I want to learn how to automate things on my computer with Python, and part of my learning process is making a project where I dont know anything and learn along the way. My goal for this particular ...
0
votes
0answers
5 views

Slow in switching tabs with Python 3 selenium in Chrome 79

Python version: 3.7.1 Chrome Version: Latest (79.0.3945.79) It takes 4 seconds to switch tabs with "switch_to.window" command: (in both head mode and headless mode) browser.switch_to.window(browser....
0
votes
0answers
15 views

Python list.append(another_list) is just repeating another_list again and again

I am writing a program which goes through a loop. In the loop body it make a Python list name value and append this value to another global list values But i am having a issue that after using ...
0
votes
1answer
11 views

Python - Add custom user models in Django admin

I'm working on a project using Python(3.7) and Django(2.2) in which I have implemented my models for multiple user types with custom user model as the base model. Everything working fine except the ...
0
votes
0answers
6 views

How to classify the quality of food through image processing?

Can anyone give me a head start to how I can proceed in making a machine learning model which classifies different food and their food quality. Like for example if we give the input as an image of a ...
0
votes
0answers
11 views

python and xampp: how to get form input data?

As the title said, I want to get data from a HTML form input via Python. I know that using a python server works but I'm trying make xampp my server here. Is there a way to do that? Also, how can I ...
0
votes
0answers
12 views

Scraping the names of the accounts who liked a post on Instagram, using Python and Selenium, but only 11 names returned

I am trying to scrape the names of the accounts who liked a post on Instagram, using Selenium and Python. There was no error returned, and I successfully scraped, but only 11 names returned, while ...
0
votes
1answer
19 views

Import python file into another python file

Before this is marked as duplicate please read the full problem. So I have a folder structure like this: main.py | |_one |_ one.py |_ file.txt What i'm doing is, importing one.py into main.py ...
0
votes
1answer
6 views

Color space conversion from YCbCr to RGB using PIL library?

How to do the following using python PIL library Converting from rgb to YCrCb and vice versa Creating images out of numpy arrays Merging y, cr , cb component back into ...
0
votes
1answer
5 views

How to make predictions with a decision tree on a dataset without a target value?

Every tutorial I have found about machine learning includes testing an algorithm on a dataset that has target values and then it finds how accurate the algorithm is by testing its predictions on the ...
0
votes
0answers
8 views

How tensorflow Train, Validation, Test Works on face recognition?

I'm working on face recognition. I used to train the data using TensorFlow retrain.py my questions are... 1. How Tensorflow works? 2. is it using CNN? 3. correct me if I am wrong 4. step for ...
0
votes
0answers
5 views

tf.function and tf.while loop in Tensorflow 2.0

I am trying to parallelize loop using tf.while_loop. As suggested here, the parallel_iterations argument doesn't make a difference in the eager mode. So I attempted to wrap tf.while_loop with tf....
0
votes
0answers
7 views

module 'collections' has no attribute 'Callable' in beautiful Soup

I'm trying to extract the whole html but it shows attribute error.Whats wrong with my code?
0
votes
0answers
9 views

django middleware modify response message [duplicate]

I need to write a custom django middleware where i need to modify the response message from the view.Is it possible with process_response method of the middleware something like this class ...
1
vote
1answer
16 views

Django session deletion effects another django application

I have two applications running on the same server with different ports and with their SQLite DB's are also different which is used to store user sessions data. if request.session.exists(...
0
votes
0answers
7 views

bcp utility from IO and not actual file

Is it possible to use the bcp utility without actually passing a file but a memory buffer instead? Pandas can do a to_csv with StringIO but that buffer cannot be passed to the bcp using this library ...
-8
votes
0answers
34 views

It is a question related to file handling [closed]

count = 0 number = 0 myfile = open("text.txt", "r") for line in myfile: line = line.rstrip() line = line.split() if not count: number = len(line) count = count + 1 if ...
0
votes
1answer
12 views

How to remove repition of documents in mongodb using pycharm

I just coded a database for my project and when I open the database in MongoDB Compass it repeates the data every time the compass is loaded.
0
votes
0answers
26 views

Find all possible subsets to get a sum equal to a given number? [closed]

To find possible subsets that sum up to a given number, with contrains that you can not use number greater than a 'max' number. sum = 4 max = 3 Allowed output: (1,1,2),(1,2,1),(2,1,1),(1,3),(3,1),(...
0
votes
1answer
17 views

Django: Problem with Adding Editing and Deleting Functionality in Django Form with TemplateView

I am learning Django by building an application, called TravelBuddies. It will allow travelers to plan their trip and keep associated travel items (such as bookings, tickets, copy of passport, ...
-1
votes
1answer
28 views

How to eliminate overlapping lines in python?

I have a list containing a list of coordinates each representing a line in an SVG path. In some cases there will be smaller lines that fully overlap another one. For example: lines = [[1, 1, 2, 1], ...
1
vote
1answer
24 views

How to efficiently segment NumPy array by creating separate binary arrays

I'm trying to separate distinct objects in an image stored in the form of a NumPy array. For instance, if I have the 2D NumPy array: X = np.array([1.4E14, 1.4E14, 1.6E14], [1.4E14, 1.6E14, 1.6E14], [...
0
votes
0answers
12 views

Python 3 Django 3.0 Running but not listening or opening port

I am using PyCharm and an instance running in AWS for remote debugging. When I start debugging the server starts and continues to run. However, it is inaccessable and doesn't appear to be grabbing ...
0
votes
0answers
14 views

Hitting 500 error on django with debug=False even with ALLOWED_HOSTS=[“*”]

I am getting 500 errors on every page I try to go with. The only thing that i'm changing is DEBUG to False. Here is my config: SECRET_KEY = os.environ.get("SECRET_KEY", "0$ke!x1bz5cj0mpzo1zfx4omw-...
0
votes
1answer
10 views

django, update modified_at when doing update()

Following field gets updated whenever model_obj.save() happens. modified_at = models.DateTimeField(auto_now=True, db_index=True) However, it is not updated when doing MyModel.objects.filter(id=...
0
votes
0answers
6 views

Tensorflow data validation serialization error

I am running tensorflow data validation v0.15 on python v3.5. I am trying to calculate the default set of statistics for anomaly detection pdf=spark.table("xxx").toPandas() # Small DF, fits into ...
-2
votes
0answers
14 views

Is Django REST framework suppose to be public?

I recently found some security holes in my university website. Among other issues was that, a page for viewing and managing api requests, using Django REST framework was found to be public. There were ...
0
votes
0answers
11 views

Matplotlib click events not working on multiple tkinter window

So I implemented this in the main window. And everything works fine. And whenever input_button is called a new window is created canvas = FigureCanvasTkAgg(f, self) f.canvas....
0
votes
0answers
17 views

Why column name with Many to Many relationship doesn't get retrieved? SQLAlchemy

I have the following model: class Actividad(Base): __tablename__ = "Actividad" codigo = Column(Integer, primary_key=True, unique=True) productos = relationship("Producto_Actividad") ...
0
votes
2answers
20 views

Python - Loop through User input number, calculate and output the entered values

I have been learning Python for nearly 6 weeks now and below is my first program. What I would like to get are user input for patient no, carb, protein and fat requirement. With the below code, I ...
0
votes
1answer
29 views

BeautifulSoup html.parser does not show all the source code

Firstly, I'd like to scrap the values off of this table on this URL: https://www.trademap.org/Product_SelCountry_MQ_TS.aspx?nvpm=1%7c076%7c%7c%7c%7cTOTAL%7c%7c%7c2%7c1%7c1%7c2%7c2%7c3%7c1%7c1%7c1 ...
0
votes
0answers
16 views

Can I set up PYTHONPATH for Lambda Function of Cloud9?

I created 2 Lambda Functions from AWS Resources menu in Cloud9. I wanna have common modules for these Functions. I made New Folder for the common modules and add the path ~/environment/python/lib to ...
-2
votes
1answer
28 views

Python — how many elements present in a list [closed]

st = 'Print every word in this sentence that has an even number of letters' x = [st.split()] len(x) Why is the output showing 1? It should be 13.
-2
votes
0answers
10 views

How to specify geometry in tkinter?

I am Trying to learn tkinter.when I used geometry method of tkinter,it shows an error: _tkinter.TclError: bad geometry specifier
-4
votes
0answers
13 views

CSRF verification failed only in production, Django [closed]

{% csrf_token %} is set. Tried @ensure_csrf_cookie as well. code: views.py: https://bpaste.net/show/UANTI template (landing.html): https://bpaste.net/show/P5YJA form_fields.html: https://bpaste....
0
votes
5answers
35 views

Replace only if “.” is the only value in a data frame column in python

I have a data frame that I am working with where missing values are specified with a dot (".") and I'm trying to replace the missing data with "Not_Given". However, some other columns have "." within ...
0
votes
0answers
6 views

Using Ansible to execute a bat file in windows machine

I have executed bat file in a windows machine using ansible by below command.It executes perfectly. I want to execute it in cmd where it command prompt keeps open. - hosts: windows1 tasks: ...
-2
votes
0answers
16 views

WinError 267 The directory name is invalid

I tried this code in jupyter notebook, and this error occured. Error : [WinError 267] The directory name is invalid: 'plantdisease/PlantVillage/Pepper__bell___Bacterial_spot/0022d6b7-d47c-4ee2-ae9a-...
0
votes
1answer
33 views

chessboard pieces won't display

Code: import tkinter, os from PIL import ImageTk, Image def sortFileImages(files): black = [i for i in files if 'black' in i] white = [i for i in files if 'white' in i] pawns = [[i]*7 ...
0
votes
1answer
12 views

Tensorflow tf.map_fn errors

a = tf.constant([[1, 2, 3, 1], [4, 5, 6, 1], [7, 8, 9, 1]]) mul = tf.constant([1, 3, 2]) result = [] for i in range(3): print(a[i], mul[i]) result.append(tf.tile(a[i], [mul[i]])) with tf....
-1
votes
0answers
7 views

Is there a way to cookie a “button disable” for each buttons with each unique ID? (Python, Flask, Web App) [closed]

Im doing a project for my school which is building a webpage using flask. I'm almost done with it. I have a page where it renders "motions(form data from users)" from my silly database. (yes, a.txt ...
1
vote
1answer
13 views

How to clear buffer of SScursor using pymysql?

I tried the following codes (from pymysql test code): https://github.com/PyMySQL/PyMySQL/blob/master/pymysql/tests/test_cursor.py def test_cleanup_rows_unbuffered(self): conn = self....
0
votes
2answers
32 views

How to make this function work more efficiently to count dominators?

I have to make a function where it would count the amount of dominators in a given list (number to the right of any number has to be smaller for it to be counted as a dominator.) For example, given ...
1
vote
1answer
18 views

Website works with half my webscraping code but other half gives an error message

I am new to web scraping and am having a hard time figuring out how to manage an issue: The website I am scraping is cooperating with half my code but now for the other half. I am scraping data from ...
-3
votes
0answers
16 views

How do I turn a table of a set of answers and the corresponding recommendations into a Python program? [closed]

I'm learning Python and I would like to develop a simple app. How do I turn this tableRecommendations of 3D printing materials (Link to table)into a python program whereby there is a questionnaire ...
0
votes
1answer
19 views

How to create clusters/groups from knowing associations?

I have a dataframe that has 2 columns: [ID, ASSOCIATED_ID] For each ID, I have a list of other associated IDS from the dataframe. Here is a synthesized version of it: ID ASSOCIATED_ID 1 ...
1
vote
1answer
24 views

What is the most elegant way to go into a subdirectory, run a command, and come back out?

I have the following directory structure. data 2019-12-11 2019-12-12 ADAZ19.json BCHZ19.json I want to go in, run a tar command from os.system, and then go ...
2
votes
2answers
21 views

Write an txt file with fastq pair names with python

I'm new to python and want to improve it. Now I want to write a python script to organize my fastq file names into a txt file, like this: My files are like this: d1_S10_L001_R1_001.fastq ...
-1
votes
2answers
20 views

Taking a users input and saying it is part of a bigger category

Say for example that I have an Array of samples = { "Object": "chairs", "Stationary": "pencils", "Thing": "apples", } And I have a code saying print('Which stuff would you like?') ...
0
votes
0answers
9 views

How to make multithread socket on different vms

I want to implement multithreaded-server receives connection from multiple clients on different VMs. 3 VMs are in the same subnet. I would ask how to make it can connect to each other by configuring ...