Questions tagged [python]

36674 questions
1

votes
0

answer
263

Views

html canvas+ Javascript on client side and python on serverside

I am trying to create a small tool very similar to https://www.circuitlab.com/ I am thinking of using HTML5 canvas to create diagrams ( possibly with kinetic.js) and make use of Javascript to create graphics. I want each diagram to be mapped to a model which will run on the server side when called....
abcd
0

votes
0

answer
267

Views

After installing opencv, python gives Import Error saying it can't find library

I'm using Kivy on Mac OS X. I installed opencv under Kivy's virtualenv. But then when I tried import cv2 it gave me this Import Error: Traceback (most recent call last): File '', line 1, in ImportError: dlopen(/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/cv2.so, 2): Li...
Ning
0

votes
0

answer
6

Views

Runing 2 cuda processes simultaneously lowers fps

I have used the YOLO repository to train a model. GPU - GTX 1080 TI (12GB VRAM) For measuring the FPS, I have written a simple python script that processes video files. When I run the python script from one terminal on a GTX 1080 TI, I get an FPS of 109 frames per second. When I run the python scri...
Blue
0

votes
0

answer
8

Views

Dropdown menu using Flask, Boostrap and Sqlite

I am new to Flask. I have used Bootstrap to design the pages. I have made a layout.html and inherited it into the home.html page. In the back-end, I have created an sqlite database defined by my models.py and I have populated it with values models.py from app import db class Line_info(db.Model): i...
Bitsy
0

votes
0

answer
502

Views

NoReverseMatch error in Django Tutorial

I'm following the Django tutorial and have got half way through this page:Django tutorial I get the error 'NoReverseMatch' with the exception value being 'Reverse for 'vote' with arguments '(None,)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['polls/(?P[0-9]+)/vote/$']'. I have gone...
angry_badger
1

votes
0

answer
164

Views

What is the different from string's “+” operation between Golang and Python?

I found String's '+' operation is so slowly on Go: func main() { start := time.Now(); s := '' for i:=0;i
LWH
0

votes
0

answer
26

Views

Use “functions in class A” in __init__ of class B after inheritance [duplicate]

This question already has an answer here: Call a parent class's method from child class in Python? 14 answers I've read several threads such as use variable in class A to be in class B in python, How to call a function from another class in python?, and Call Class Method From Another Class, but sti...
ytu
0

votes
0

answer
11

Views

How to measure information diffusion in social network

Recently I am working on predicting information diffusion in the social network. I want to know how to properly measure information diffusion. For instance, when a new topic is generated at time t0, it will propagate through the social network such as Twitter. How fast and amount of that topic spre...
Jessica Sheng
1

votes
0

answer
183

Views

Quicker Way to Parse a FASTQ file?

I currently have a list of 300,000+ FASTQ identifier codes that are used to parse a file. My file structure is currently set up like this: @[FASTQ identifier] [random text] [DNA sequence] + [DNA sequence quality score] This 4 line structure is repeated throughout the file. The way my current scrip...
superasiantomtom95
0

votes
0

answer
25

Views

How to pass user input from AngularJS to Python backend- timezones that are not local to client

I tried asking this question, about how to pass user input from AngularJS to Python backend. The question has been marked as a duplicate of Getting the client's timezone in JavaScript question, and closed- I looked at the question it was referenced as duplicating, and while it is relevant, it appear...
someone2088
0

votes
0

answer
44

Views

How can I redirect method's output into a txt file in python [duplicate]

This question already has an answer here: Redirect stdout to a file in Python? 10 answers I have created a GUI using PyQt and now I want to direct the input in QlineEdit into the text file. I have created get_values() method which prints the values from the text fields. How can I redirect those pri...
0

votes
0

answer
5

Views

vagrant up eos freezes system completely, not able to bring up eos

I am just learning to use the python NAPALM library. The tutorials suggest set up a lab using VirtualBox and Vagrant, with a virtual Arista device I am not able to bring up eos. I am having the following configuration : ubuntu : 16.04 LTS, OS type 32-bit virtual box : Version 5.2.22 r126460 (Qt5.6....
user3282758
0

votes
0

answer
16

Views

Only single thread executes parallel SQL query with PySpark using multiprocessing pool

I have a case where I am using PySpark (or Spark if I can't do it with Python and instead need to use Scala or Java) to pull data from several hundred database tables that lack primary keys. (Why Oracle would ever create an ERP product that contains tables with primary keys is a different subject......
devinbost
0

votes
0

answer
20

Views

Rotating an image using own algorithm

For an uni assignment I have been giving the task of making my own rotating algorithm in python. This is my code so far. import cv2 import math import numpy as np class rotator: angle = 20.0 x = 330 y = 330 radians = float(angle*(math.pi/180)) img = cv2.imread('FNAF.png',0) width,height = img.shape...
Zorn01
-1

votes
0

answer
29

Views

How to suppress python logging info like this?

After I changed the python interpreter in lab's server(using conda),the program began to print log info like this: [INFO/Process-2] child process calling self.run() [INFO/Process-2] created temp directory /tmp/pymp-1dirqb4e [INFO/Process-1] created temp directory /tmp/pymp-zu758xh9 I'm not sure whic...
Lucas
1

votes
0

answer
39

Views

Since python is written in C, is it compiled to C then to asm then to binary code? [on hold]

Or is it wrong to assume this? How does it work backward? When I hit run in my python IDE, the python code gets compiled into assembler?
ERJAN
0

votes
0

answer
52

Views

Why I am getting this error “ImportError: No module named pyplot” while using matplotlib in Python

I downloaded matplotlib wheel file and installed it using pip and it got successfully installed. But the matplotlib does not contain pyplot. What should I do? import matplotlib.pyplot as plt import numpy as np t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2*np.pi*t) plt.plot(t, s) plt.xlabel('time (s...
Sagnik Sarkar
1

votes
0

answer
375

Views

Python Path error - No Module Found error

I'm having issues running ortools on Linux. I downloaded it from google's site (https://developers.google.com/optimization/) and installed it using 'make install,' but when I go to use it in python I get the following: Traceback (most recent call last): File 'regular.py', line 42, in from ortools....
Max
0

votes
0

answer
75

Views

“{:,}”.format(number) compatibility in Python 2.6 [duplicate]

This question already has an answer here: How to print number with commas as thousands separators? 26 answers I am converting a number from (1000) to 1,000) or 12345678 to 12,345,678 But this does not work in python2.6. What is the equal method that can run in Python2.6? Or there is something else...
Clayton
-1

votes
0

answer
12

Views

how can i make matlab graphics in matplotlib?

my current topic is, Model in the time domain of systems, By chance I found an exercise in matlab that is as follows: x = ones(1,41); b = 0.7; a = (1-b)/(1-b^5); i =1:5; w = a * (b.^(5-i)'); for n=5:40; y(n)=w*(x(n-4:n)); end; n=5:40; plot(n,y(n),n,y(n),'o','LineWidth',1.5) grid xlabel('n') ylabel('...
royer
-1

votes
0

answer
13

Views

I want to make a Dynamic URL with flask by reading and matching list of files from a directory

This is my code which reads a specific directory which contains vip1.json, vip2.json, .... vip10.json @app.route('/', methods=['GET','POST']) def vip(num): for filenames in os.listdir('C:/pytest/submitted_form_data'): if filenames.endswith('.json'): print(filenames) The above works fine, it lists ou...
Bharath
0

votes
0

answer
29

Views

Finding numbers in a list of permutations based on the position of one of the numbers in the list

I've been coding a program that solves a maths problem with specific conditions. In this maths problem, there are seven slots. At the beginning, the first three slots are occupied by the numbers 1, 2 and 3. There is an empty slot in the middle. The next three are numbers 4, 5 and 6. Seven slots alt...
Ian Heng
0

votes
0

answer
5

Views

Need Entry Table with tkinter in the same window ? How to get entry with the tktable?

I am developing an application in which a list of values to be entered from the user and each time of loading of the app the rows changes hence I cannot go with the text or entry option for each time. Does anyone have any good suggestions?
rmk_pyth
-1

votes
0

answer
16

Views

How to count the sums of the different values in one column and group them by another column to create a pie chart

I want to count the number of occurrences of each of the different boroughs in the Program Borough column and group them by the Contract Type to create subplot pie charts for each Contract Type. My goal for each is to show what percent of that contract type comes from each borough. Here is my code...
blackholeprime
-2

votes
0

answer
16

Views

Python multiprocessing timestamp takes a lot of time

I created a program that spawn processes and run the provided algorithm. When i run the algorithm without multiprocessing it takes 1.7 sec, but when i spawn two processes that run the same algorithm it takes 18 sec. Profiler result for one process without spawning: 68050 0.084 0.000 0.084...
1

votes
0

answer
161

Views

Does it make sense to detect keypoints with SIFT and describe them with SURF or ORB?

I'm working on a computer vision classification project and I'm trying different detectors and descriptors. I use opencv 3 and python and I saw that it is possible to locate keypoints with SIFT and describe them through SURF or ORB descriptors. The same applies to other combinations of these 3. When...
Ingen
0

votes
0

answer
41

Views

How to get margin intersections and area of each labeled component?

I have segmented a binary image using expectation maximization. After that, I used OpenCV to labeled connected components by using the below implementation: image = image.astype( 'uint8' ) nb_components, output, stats, centroids = cv2.connectedComponentsWithStats(image, connectivity=8) sizes = stats...
Tarcisiofl
0

votes
0

answer
66

Views

Unable to connect docker mysql via django

I'm using docker as MySQL server, in docker I use: docker run --name what -e MYSQL_ROOT_PASSWORD=abc123 -e MYSQL_DATABASE=mami -p 3306:3306 -d mysql After that I tested it in MySQL workbench. It works fine with 192.168.99.100:3306 and root/abc123 but when I try to connect it via django: import pymy...
0

votes
0

answer
8

Views

How to convert a huffman byte array to string python

I just finished creating a huffman compression algorithm . I converted my compressed text from a string to a byte array with bytearray(). Im attempting to decompress my huffman algorithm. My only concern though is that i cannot convert my byte array back into a string. Is there any built in function...
Mohamed Alremeithi
0

votes
0

answer
95

Views

Pandas 'Incorrect information in file' using to_sql Method

I have a pandas dataframe and am writing to a SQL database via this code: df.to_sql(con=conn, name='temp', if_exists='replace',index=False) It throws the following error. I'm wondering what this error means, why its getting displayed, and how do I fix it?: Traceback (most recent call last): File '/h...
Jason Melo Hall
2

votes
0

answer
101

Views

Difficulty reading from stdin [duplicate]

This question already has an answer here: How do you read from stdin in Python? 19 answers I need to make my script usable for UNIX commands, in order to make it possible for example to process 2 input files at once with my script. This script works perfectly well with command line arguments: newli...
user3241376
0

votes
0

answer
617

Views

ValueError: No variables to save in tensorflow with object_detection api

I am using the object_detection api to train my own images. The error happened when I ran the train.py: Traceback (most recent call last): File 'train.py', line 163, in tf.app.run() File '/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py', line 48, in run _sys.exit(main(_sys....
looori
0

votes
0

answer
348

Views

IndexError: list index out of range(to install tensorflow)

i'm installing tensorflow,the command is: $pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl and the error appeared: raise SSLError(e) SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol Storing debug log for failure in /hom...
evbo
0

votes
0

answer
137

Views

Best Practice for Storing Event Dates

I am building an mobile app for event notifications. I scrape events from various websites. In my app I list events near a clients location and I allow them to search for events that could be located anywhere in the world. Since the event dates are fixed in some timezone they don't need to be conver...
MoreScratch
0

votes
0

answer
17

Views

Identifying ultimate parents in pandas dataframe

I have the following dataframe with a column of Child and a column of Parents: import pandas as pd df = pd.DataFrame({'Child': ['A1', 'A2', 'A3', 'A1', 'A1', 'A4', 'A2', 'A3'], 'Parent': ['B1', 'B2', 'A2', 'B3', 'A4', 'B4', 'B5', 'B6']}) df Child Parent 0 A1 B1 1 A2 B2 2 A3 A2 3...
prmlmu
0

votes
0

answer
48

Views

Training on Patches of VIDEO FRAMES and Quality Scores

I am working on a project in which, the CNN model is supposed to predict the Mean Square Error on patches of images. These images are frames of videos. I have split datasets (80 % - 20 %) (X_train, y_train) and (X_test, y_test). X_* contains 48x48 patches and y_* contains ground truth quality score....
sana
0

votes
0

answer
13

Views

Data Seperation in Python

I have my dataset (over Mio. lines) and want to split or separate it by one determined attribute ' for e.x: ship number. How can I do it in Python? Thanks in advance!
Hang Tran
1

votes
0

answer
568

Views

ValueError: max() arg is an empty sequence in Django

I keep getting the following Django error: ValueError: max() arg is an empty sequence when I do ./manage.py runserver Here is the full stack trace: Unhandled exception in thread started by .wrapper at 0x109183ae8> Traceback (most recent call last): File 'venv/lib/python3.5/site-packages/django/utils...
Gasim
0

votes
0

answer
34

Views

Google apiclient execution error (Python): invalid_grant

I am working on implementing Google OAuth 2.0 on a project. The Udacity course I'm taking is teaching me to use deprecated libraries, so I’ve begun using Google’s oauth2, oatuhlib.flow, and googleapiclient libraries for authentication and authorization instead. I’ve been following this Google...
Michael Lacey
0

votes
0

answer
34

Views

Remove existing formatting of csv cell copied into text editor in django

I have made a forums website in Django. The textarea for entering question has NicEdit integrated for formatting purpose. However if I copy a cell from a CSV file and paste it into the textarea and save it, the database has some extra tags added along with it. Example: On copying a cell which contai...
Pratik Ratadiya