Newest python Questions

Q&A for professional and enthusiast programmers

Tensorflow: TypeError: run() got an unexpected keyword argument 'feedis_dict'

I get this error when trying to add the feedis_dict to a self.sess.run command: Traceback (most recent call last): File "spritegen.py", line 71, in <module> tf.app.run() File "/usr/...

Why I am Getting '_SIGCHLDWaker' object has no attribute 'doWrite' in Scrapy?

I am using Scrapy spiders inside Celery and I am getting this kind of errors randomly Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/twisted/python/log.py"...

finding xml parts in a sentence with regex

I have such a line: <bpt i="1" type="1" x="1" />und ZF-Getriebe <ept i="1" />TipMatic <ph x="2" type="2" />Lite (&lt;/cf&gt;6AS850, 6AS800, 6AS1000) And I want a regex ...

Convert to date using formatters parameter in pandas to_string

I know there are several ways to convert a column to a date object, but what I am looking for is a way to do so while simultaneously formatting other columns. Say I have the following data frame: ...

Translating Python 2 byte checksum calculator to Python 3

I'm trying to translate this Python 2 code to Python 3. def calculate_checksum(packet): total = 0 for char in packet: total += struct.unpack('B', char)[0] return (256 - (total % 256)) & ...

Running a GUI program server-side over the web

I'm trying to start GUI programs on my media centre/Apache web server (Raspberry Pi running Raspbian) over LAN but can't work out how to do it using either Python or PHP. Ideally I need to run a ...

Python - Add a key (string) in a numpy array filled with float [duplicate]

I have a big array named A of arrays which follows the following structure : [ [0.453,0.5452,0.252], [0.411,0.352,0.119], [...], ... , [...] ] I have an other array named B with the same length but ...

Understanding this usage of % in Python to create an RGB color from random numbers [duplicate]

I don't understand how this statement is creating a color in Python. I would really appreciate any clarification. I see that it must be substituting in the random numbers but that is as far as I get. ...

Training a ranker with train.py script

I'm currently trying to create a ranker by running the train.py script provided by the Retrieve & Rank Documentation. I issue the following command when trying to create the ranker: train.py -u ...

How do I find the location of the Python stdout file object?

In Python I know that the standard output stream is available as the stdout file object in the built-in sys module but I'm confused: first, I'm not able to locate the sys module in the way I do with ...

Django: error: invalid command 'bdist_wheel'

I have installed the packages but met the traceback,which shows error: invalid command 'bdist_wheel'. I referenced Why can I not create a wheel in python? wheel ,setuptools --force, --upgrade pip ...

Project structure - linking models.py

Building a form to submit data to Google Datastore from AppEngine(Python). I want to move my ndb models out of main.py to their own file models.py. Both of these files sit in the root directory of ...

Why the downloaded file numbers is not equal numbers of url's line in my log file?

Platform: debian8 + python3.6 + scrapy 1.3.2. Here is a simple scrapy script to download all the us stock quote. Please to download the 7z file on webpage. all urls to be downloaded To extract it ...

Quality control of imported mesh from stl and visualization of the weak spots

I want to check an already existing mesh from a *.stl file (binary) which is not flawless and will be used for a simulation later on. Therefore I need to check it in terms of different quality ...

Optimizing (very) noisy model predictions in python

I am currently trying to fit a 5-parameters model to data in python. There's a bunch of great tools in the scipy.optimize package. However, the model is not mathematically tractable, and model ...

Data extract from text file

Please help. I have data in text file with 2 long columns tab spaced I have to extract first and second columns separately Can it be done with Python ?

How can i improve my code please {python[

import csv # imports should go at the top of the file def read_csv_file(): """ reads csv data and appends each row to list """ csv_data = [] with open("task2.csv") as csvfile: ...

Unable to find string in list [duplicate]

While I need to test a condition whether some strings are existing in the list or not, I'm getting always same answer. Like in below list I need to check for string "Inactive" or "Dead", if found ...

Where can I find a good 3D procedurally generated tree tutorial

I would like to learn how to procedurally generate a 3d Tree with Python in Maya, but I can't find any type of tutorial,any advice?Thank you

gud-pdb emacs usage and PATH

I'm trying to use gud-pdb for python debugging within emacs Having an issue that pdb doesn't seem to be searching the PATH when looking for my .py files i.e. I have a python script in a dir which is ...

What is the pythonic way to write this mathematical formulas?

This is my first post in en.stack.aiseen.org . I am beginner in python and in programming in general. I read everywhere that the best way to learn programming is to start programming. Therefore, i have ...

EOFError: Ran out of input

When I run the code below I get this error message "EOFError: Ran out of input" what does it mean?? How it can be corrected?? and how to output the records details on the screen. import pickle # this ...

Not able to eval an image in CNTK python

Below is the code I am using: import sys,os import numpy as np # import dicom import glob import cv2 import time import cntk import pandas as pd from PIL import Image from sklearn import ...

Loading one dimensional data into a Dense layer in a sequential Keras model

I have the results of a trained model, ending in a Flatten layer in numpy output files. I try to load them and use them as inputs of a Dense layer. train_data = np.load(open('...

Finding number of males, females & unspecified using python

I want to count the number of females, males and others (no gender recorded) from a csv file using python? Is there a simple way to do that? I have a column called 'gender' with "males," "females" or "...

How can I left align a Python Matplotlib pie chart?

I have a pie chart with a left aligned title: import matplotlib.pyplot as plt # Pie chart, where the slices will be ordered and plotted counter-clockwise: sizes = [15, 30, 45, 10] fig1, ax1 = plt....

Parsing CityGML with PyXB

I'm trying to parse a CityGML file in python in order to generate python objects from the buildings. Optimally the objects would have attributes corresponding to the elements in the GML, more or less ...

Turtle graphics on Ubuntu 16.10, lines that are not vertical or horizontal are not visible

The following code is supposed to draw a set of tilted squares but only vertical and horizontal lines are visible. I have installed python-tk and python3-tk beforehand. turtle.left(20) turtle....

Send CTR + D to a remote program

I've been using fabric a lot lately and I ran into a situation where a remote program I was interacting with needed me to send the CTR + D signal to it. My feeling is that I need to append some sort ...

Creating a file from a list with spaces

from collections import OrderedDict sentence= ("I met a traveller from an antique land,Who said—“Two vast and trunkless legs of stoneStand in the desert. . . . Near them, on the sand,Half sunk a ...

Pymysql cant connect Amazon RDS host, but same host is accessible through mysql workbench

I am using pymysql to connect to Amazon RDS and it fails with : db = pymysql.connect(host=Host, user=User, password=Pswd, db=DBN, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor,...

Embedded youtube-dl python, how to embed ffmpeg?

I am building a Flask application and using embedded YouTube-dl to download mp3 from YouTube, and it needs ffmpeg to be available to convert. So I made a folder in the app and placed ffmpeg inside and ...

I am getting this error “TypeError: str() takes at most 1 argument (2 given)” at “client_response” variable

from __future__ import print_function import socket import sys def socket_accept(): conn, address = s.accept() print("Connection has been established | " + "IP " + address[0] + "| Port " + str(...

importing nltk in python 3.4.0

I am new to python and using python 3.4.0. I have installed nltk and six but I am getting an error when importing.I have also tried upgrading. Its up to date. import nltk Traceback (most ...

How to make definiton work?

Please see below examples: import pygame pygame.init() x = 800 y = 600 programDisplay = pygame.display.set_mode((x,y)) pygame.display.set_caption('Title') pygame.display.update() programExit = False ...

invalid literal for int() with base 10 while using session

I'm trying to send data from one view to another. I want to access the email throughout my application so, I'm setting email to session. Now, I want to get object passing email as pk. View where I ...

How to add extra length to integer array in Python

I have a measurement device which is being read by Python into an integer array. How do I append the array with an extra 10 integer "locations"? I have tried ".extend", ".append", "+", and have not ...

python communication between different classes and .py files

I'm trying to use the mvc-model in my program. I use pubsub to communicate between my files. I was wondering if there is another way to communicate instead of using pubsub? My specific problem: I ...

How I could create a theme selector for Django (ideas, advices, …)

I'm developping and improving my Django website and I would like to get advices about graphic charts and what I can do with Django. When I'm developping my software, I adopted a graphic chart ...

Why does pandas.cut() behave differently in unique count in two similar cases?

In the first case, I use a very simple DataFrame to try using pandas.cut() to count the number of unique values in one column within a range of another column. The code runs as expected: However, ...

Inline models with images in admin model

I have two models products and products images now I want to add product and images from the admin using one single form Product Model class Products(models.Model): id = models.AutoField(...

Wasting cycles with actual arbitrary instructions with Python

I have been working on a project in which I need to create a Python application that wastes instructions & cycles at this stage. Normally when 'cycle wasting' means waiting or sleeping; but I want ...

Defining an interface and using multiple implemenations of the interface

I had problems getting my head around the implementation for the following requirement: Creating one interface class Interface. Creating n classes ImplementationN that implement the Interface in ...

Scrapy: Memory usage exceeded to 10GB

While scraping a website, memory leak occurred. help me. Task manager snap shoot image. The spider has many many requests to the website. For example the spider code looks like following: def ...

Best database for Python? [on hold]

I'm working on a desktop app that would get some information from a website and store it in a database, then search through it via a GUI. The GUI would have an 'Update' button, for the information to ...

How to ignore OSError: [Errno 2] in Python, os linux, usbtmc

I'm using python to communicate with Oscilloscope and Waveform generator via usbmtc and sometimes my usb ports are changing. So I wrote a function to detect current device: for x in range(0, 3): ...

Is it possible to use `S3 storage` as HDF5 file storage and share it with other server?

I'm gonna get tons of data via Stock API (by Korean Stock company) and trying to store all of them as HDF5 format using Python PyTable. And there is another server running Django web application. This ...

Using python's subprocess.call or os.system inside an SSH chroot jail

Ok, the situation is a bit hard to explain. I have a user in an SSH chroot jail. I copied some binaries and all the necessary libraries, and it works. However, when I try to use os.system or ...

Why flask background thread get wrong database information?

In order to push real time database info to client, I use flask-socketio in server side by using websocket to push all real-time database info to client. There is a snippet of my view file: from .....

removing outer nesting of python dictionary

I have a python dictionary which looks like as follows: {u'start_time': u'1437056839370', u'playback': {u'duration': u'873041'}, u'end_time': u'1437058474763', u'id': u'...
Translating... 0%