Questions tagged [python-3.x]

58131 questions
1

votes
0

answer
77

Views

Pixel control in terminal with Python

I am just getting to grips with modern programming having previously dabbled in QBasic as a child. In QBasic I could run in DOS and write a program which would control individual pixels on the screen. I was able to do quite a lot graphically with this without having to worry about windows etc. I've...
Luke Richards
1

votes
0

answer
306

Views

run a function in python as non blocking thread

I am simulating a use case in which clients send a request to the server for a particular service time and then, the server creates a new VM for each client request and then stop VM and destroy VM when service time is over. For simulating this behavior, I have made a client request generator whic...
Amarjit Singh
1

votes
0

answer
1.1k

Views

Pandas Styling HTML with Style.apply [duplicate]

This question already has an answer here: How to use `style` in conjunction with the `to_html` classes on a DataFrame? 1 answer Change the color of text within a pandas dataframe html table python using styles and css 2 answers I am trying to use my highlight_diff function to compare two dataframe...
Tyler Russell
1

votes
0

answer
29

Views

How to pass several values as nosetests' options in setup.cfg?

I currently run my tests with : nosetests3 -vd -w . module1 module2 ...And I would like to automate these options. However, I can't find a way to pass several values to an option... I tried this : [nosetests] verbosity=1 detailed-errors=1 where=. module1 module2 ...But it replies ValueError: Worki...
hl037_
1

votes
0

answer
189

Views

I am trying to change the value of an exposed variable in RPyC. I receive an error. What am I doing wrong?

I am using RPyC for a client-server application. I try to change the value of exposed_variable when I call exposed_change() method. I receive 'UnboundLocalError: local variable 'exposed_variable' referenced before assignment' error. However, if I make exposed_variable global (before I try to modify...
SomeoneNew
1

votes
0

answer
55

Views

Using tqdm with a class and arguments

Im attemting to use tqdm and multiprocessing to run through a range of values and pass that same range value into the class im calling as an argument. I can't seem to find anything useful online on how to pass arguments of the iteration into the fuction call (in my case im calling a class function),...
iNoob
1

votes
1

answer
37

Views

Python 3.6: Using object instance name for raising errors

I'm attempting to create a 3-d graphics engine using Python 3.6, Tkinter, and specifically NOT pygame (or any other 3d graphics engines) as part of a university assignment. Within this project, I have had to create a 'matrix' class, which allows me to easily create and manipulate mxn matrices. I bel...
William Pulford
1

votes
0

answer
349

Views

Python 3.5.x multiprocessing throwing “OSError: [Errno 12] Cannot allocate memory” on a 74% free RAM system

I wrote a Python 3.5 application that spawns several processes using multiprocessing library. It runs on Ubuntu 16.04.3 LTS on a dedicated server machine that ships with 2 x Intel Xeon E2690 v1 (8 cores each) and 96GB of RAM. This system runs a PostgreSQL instance which is configured to use a maximu...
pietrop
1

votes
1

answer
231

Views

execute python script from cron don't send mail

I've script in python that takes photos from raspberry camera and send mail with this photos. From command line everything works OK, script start do the jobs and finishes without errors. I setup cron to execute script every 1 hour. Every hour I get mail but without attachments. Where or how can I...
kolo
1

votes
0

answer
75

Views

PyQt4 not found, despite file existing on the backend folder.

I am trying to run a code to get an interactive GUI. However, I get the following error while trying to use %matplotlib qt: So, I tried using %matplotlib qt5 and the problem still persists. I've checked the backends folder. I seem to have both backend_qt4agg and backend_qt5agg. I am using Conda 4....
hegdep
1

votes
1

answer
207

Views

Fortran Extensions in >=Python 3.5

I am attempting to build Python extensions that include f90 code for Python 3.5 and newer. Previously, I was able to use the MinGWPy project to build extensions with gfortran. However, MinGWPy doesn't support Python 3.5 and newer, and has recently been discontinued. How can I build Python extensions...
Paul Wells
1

votes
2

answer
166

Views

I am having errors with Django authenticated built-in function

I have been woking in django for a while. Now i am facing some problems with built-in function in django. The error state that TypeError: 'bool' object is not callable. This kind of error happened because of statement 'print(request.user.is_authenticated())'. Here below is source code: def login_pa...
I Love Coding
1

votes
0

answer
56

Views

Get the evaluation of if statements in Python pdb

I am new to pdb. I use python3 -m pdb myscript.py in the command line interface. I am currently using s to trace code step by step. There are many if statement in the code that I want to know what they are evaluated to while tracing. The way I am doing now is p if-statement-that-I-am-interested-in t...
Tai
1

votes
0

answer
51

Views

import python statements not working when called from JS

I'm unable to run my Python code from node.js. The following is the Python code I'd like to run: from preprocessor import pad_vec_sequences, labels from keras.models import load_model import spacy from preprocessor import nlp import numpy as np import sys from dependency_tree import to_nltk_tree , t...
Nirvan Anjirbag
1

votes
1

answer
634

Views

Python PyPDF2 counting PDF pages in scanned PDF generates Xref table not Zero indexed

I have written a fast script to count the pages in PDF files. However, in some files it cannot be read and it returns an error of Xref table not Zero indexed. Basically when expects an Object Id (5.0) and gets Object Id (4.0) for example. Also I have got with other Object Id like (7.0) and gets Obje...
TMikonos
1

votes
1

answer
52

Views

How do I represent subflows in Python Luigi task manager?

Suppose I have flow A->B. Users of this flow require B. Suppose I have a task C which requires B but I want D to happen before flow A->B. How do I do this in Luigi?
Lars Ericson
1

votes
0

answer
145

Views

Python/Kivy : How to pass TextBox value in .kv file from one class to another class

Can anyone tell me? I have two file test.py and test.kv. I have a textBox which id : state . How to pass state.text value in root.get_value(state.text) and get value in function of def get_value test.py from kivy.uix.screenmanager import Screen from kivy.app import App from kivy.lang import Builder...
Martin
1

votes
1

answer
180

Views

Numpy arrays from tuples of arrays for matrix based neural networks

To implement learning in a neural network I'm using stochastic gradient descent in which the mini batches are represented via the following list comprehension: mini_batches = [training_data[j:j+mini_batch_size] for j in range(0,len(training_data),mini_batch_size)] Inside the list comprehension the s...
sunspots
1

votes
0

answer
85

Views

Machine Learning Python output predictions

I have some code to analysis and predictions data sets. In my code predictiosn are onlt 0 or 1 but in my data.csv I have from 1 to 7 output. In verbose mode output can be 0 or 1. How can I solve problem to predict output as 3,4 etc. Here is my data set first 10 row: 1,2,4,4,1,1,3 1,2,4,4,1,2,1 1,2,4...
burakr9
1

votes
0

answer
190

Views

speeding up a python3 rabin-karp implementation

I'm trying to implement rabin-karp for a programming challenge. my implementation is correct, but apparently it's too slow (the organizers have a time limit for each language, and my running time is double the limit! ) I use polynomial hashing, and use the rolling hash strategy. Is there a way to sp...
strum
1

votes
1

answer
265

Views

can't download .XLS file from url using selenium python. Always end up with Firefox download popup

I have tried various methods but I'm unable to download excel file. I always end up with the firefox popup staring at me. any Idea how to get this working import time from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By fr...
Rahul Mishra
1

votes
1

answer
19

Views

Python read data from mysql errors

I want read a column from mysql ,multiply a factor and write into mysql cursor = db.cursor() query = ('SELECT GDP FROM selectedairport') cursor.execute(query) gdp_list = [] for GDP in cursor: gdp_list.append(GDP) weight = 0.5 num = gdp_list * weight cursor.execute('UPDATE `selectedairport` SET `sele...
Trux
1

votes
2

answer
243

Views

exit program stuck on sys.stdin.readline

I have a thread waiting on input, but in the event that no input is provided, I need to exit the program. How can i exit the program? in this example the exit should be triggered by keyboard ctrl+c however I would also like to do this without interaction ie via a timeout or other event. import threa...
pstanton
1

votes
2

answer
1.8k

Views

Security Issues with Anaconda?

There has been some back and forth between myself and the IT department of a company I recently began working regarding the installation of Python / Anaconda suite on my work PC. The IT department is making claims of security risks (with Anaconda) but I suspect it’s more of a matter of them not w...
lewisj
1

votes
1

answer
549

Views

Python|Keras: how to define a callback to interrupt/exit training per user's request

Currently, I can 'safely' interrupt Keras neural net training via: early stopping callback (once accuracy improvements are small) stopping the execution and restarting from the last saved model However, I'm looking for a way to have a more robust way to interrupt the training. Is there a way to cr...
Oleg Melnikov
1

votes
0

answer
20

Views

logger: DEBUG and INFO not logged (handler and level set)

I want to log DEBUG and INFO to stdout and the rest to stderr. I set up a filter and am creating a logger with two different handlers: import logging # https://stackoverflow.com/questions/16061641/ class InfoFilter(logging.Filter): '''Filter used to catch DEBUG and INFO for stdout_handler''' def fil...
Jimmy Sanchez
1

votes
1

answer
160

Views

How do I bind a member_descriptor to a class without a reference in class.__dict__

Since my privatization trick works in both IDLE and the python3 REPL: >>> class A(object): ... __slots__ = ['attr'] ... >>> dscget = A.__dict__['attr'].__get__ >>> dscset = A.__dict__['attr'].__set__ >>> del A.attr >>> but not quite in my program (same exact setup and mechanics) Python 3.4.3 |...
Tcll
1

votes
0

answer
68

Views

Python requests.put, how to set key to null

Does anyone know how to send None with requests? As I understand that by having None will make Python ignore 'port_id' and that it will not be included in the body. Is there a way to change that and make sure None is sent? data = {'port_id': None, 'token': TOKEN} r = requests.put(URL + 'api/port/'+...
Alberto Santos
1

votes
1

answer
26

Views

Importing a file in python

I tried to import the file only using import I searched the problem and found out it happened because the file isn't in the same working directory as my current file, didn't quite understand that(I am a beginner). So I tried using this: But still I get this error No module named printer1. Here is t...
Programmingfreak
1

votes
1

answer
264

Views

My socket program doesn't print the output

Just getting started with socket programming, I have created the below code and expecting to print some byte data, but it isn't doing that. import socket def create_socket(): s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohl(3)) while True: rdata, address = s.recvfrom(65535) print(rd...
Vignesh SP
0

votes
1

answer
18

Views

How to fix “index out of range” for files in lists

I'm currently creating a quiz from a File. I want to store the questions in one list and answers in another list. The questions are formatted as 'What is the capital of France? Paris'. There are a total of 15 questions but only 10 need to be asked. Which are randomized. I keep getting IndexError: li...
Michelle
1

votes
1

answer
14

Views

Get protocol and domain (WITHOUT subdomain) from a URL

This is an extension of Get protocol + host name from URL, with the added requirement that I want only the domain name, not the subdomain. So, for example, Input: classes.usc.edu/xxx/yy/zz Output: usc.edu Input: mail.google.com Output: google.com Input: google.co.uk Output: google.co.uk For more co...
cs95
0

votes
1

answer
15

Views

Python run external executable

I am trying to run an external executable, that requires complex parameters and capture the output in a variable. How do I do this? import os import subprocess subprocess.call('C:\\bin\\test.exe', ' -b10.10.2000',' -house50.20E,10.40N',' -hsyE',' -utc00.18',' -eswe',' -sid27',' -fPls',' -head',' -g'...
Kapish M
0

votes
0

answer
15

Views

MySQL Join twice on the same table gives half of the result

I have 2 tables and making join query, thing is that in the main table I have 2 columns with id which needs to be replaced with full names from second table, thats why I am running query over same table twice. Thing is that it hasn't roughly half of the records, if I change position of joins then se...
0

votes
2

answer
24

Views

How to read in user input on a webpage in Flask

I'm trying to create a basic web app that has an HTML form on the root landing page, and then after submission, run a postgresql query with the desired input and redirect the user to a page with a generated matplotlib chart of their input. In my main function, I have the following: @app.route('/', m...
danielschnoll
0

votes
0

answer
4

Views

Would there be any way to download a mailing listserv archive on Freelists.org as an mbox format using Python or other techniques?

I am attempting to find a way to download the following listserv archive in an mbox format using Python: https://www.freelists.org/archive/program-java/ Would there be any easy way to achieve this goal? I am trying to employ text mining techniques for one of my intrest groups. However, although the...
Justin
2

votes
1

answer
16

Views

How do I implement a breadth first and depth first search web crawler?

I am attempting to write a web crawler in Python with Beautiful Soup in order to crawl a webpage for all of the links. After I obtain all the links on the main page, I am trying to implement a depth-first and breadth-first search to find 100 additional links. Currently, I have scraped and obtained t...
dacoda007
0

votes
2

answer
11

Views

how to receive username with token by django rest authetication?

I am using django Django=2.1.7 and rest framework djangorestframework=3.9.2 This is my url for login path('rest-auth/login', include('rest_auth.urls')), When I enter username and password I got the token from rest API. But I want my user detail like name, id etc to show in my react components. Pleas...
imsaiful
1

votes
0

answer
14

Views

How to check if two strings are equal recursively in Python? If equal, return 1, otherwise, return 0

def compare(s1, s2): if s1 == '' and s2 == '': return 1 if len(s1) != len(s2): return 0 if s1 !='' and s2 == '': return 1 else: compare(s1.strip(s2[0]), s2.strip(s1[0]))
Sam Tang
0

votes
0

answer
10

Views

Unable to attach a excel file which created from pandas dataframe in email from python

I am reading an file from amazon S3 and then doing some data manulipations in pandas and then sending an automoated email . The filename is always is going renamin the same . I am trying to convert the dataframemodelput to xls file and attach it in the email How to fix this My code import os import...
Rahul rajan

View additional questions