Category "python-2.7"

properly logging unicode & utf-8 exceptions in python 2

I'm trying to log various exceptions from libraries in python 2.7. I find that sometimes the exceptions contain a unicode string and sometimes a utf8 bytestring

pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python

I am trying to I am tring to delete stop words via spark,the code is as follow from nltk.corpus import stopwords from pyspark.context import SparkContext from

OpenCV Python - No module named cv2 (again)

I know that this question has already been asked here a few times, but since no answer helped me so far, I'm posting it here again. What I did: I cloned the r

How to convert a given ordinal number (from Excel) to a date

I have a Value 38142 I need to convert it into date format using python. if use this number in excel and do a right click and format cell at that time the value

Can't import rest_framework in Django

I'm trying to stand up a Django site and I am attempting to setup Report_builder with that. I just got the front end of report builder to work but it is not ret

Scapy send packets speed up in Windows

In Windows I need to send an NBNS name query packet (which uses UDP protocol), and I need to send 255 packets and get an answer for each. With Scapy it takes a

python get form data how can this be?

This is my js function for ajax form submit: $('.sendButton').on('click', function(){ $.post( "/send-form", $('#contactForm').serialize()) } This is my f

How to add watcher to JIRA ticket using JIRA python API

I am using JIRA python API to create JIRA tickets from my code. The code looks like below from jira.client import JIRA def create_jira_issue(jira, summary, des

pandas astype python bool instead of numpy.bool_

I need to convert a pandas dataframe to a JSON object. However json.dumps(df.to_dict(orient='records')) fails as the boolean columns are not JSON serializa

List within single quotes [duplicate]

I have a list which is in single quotes. '[{"Name":"name1","value":"value1"},{"name":"name2","value":"value2"}]' I receive this as an input p

Python OpenCV - Extrapolating the largest rectangle off of a set of contour points

I'm trying to make an OpenCV detect a bed in the image. I am running the usual Grayscale, Blur, Canny, and I've tried Convex Hull. However, since there's quite

Making a certain statement loop forever in Python

while 1 == 1: do = raw_input('What would you like to do?') In the above example you can see that the code is meant to make something loop forever, for exam

python animation.FuncAnimation error : object is not iterable

I'm new to Python and now studying matplotlib to use animation function. I'm following qutip tutorial because of my study. But when I copied and pasted example

Tensorflow serving error: "Data loss: Can't parse saved_model.pb as binary proto"

I used google collaboratory to train a simple mnist example model to get myself familiar with tensorflow serving but my tensorflow model server is not able to r

How to create a password protected zipfile using the zipfile module

I have a password protected zip-file called important.zip, it contains 1 folder, the password for the zip-file is 123, however when I use run this code with a w

python: argparse throwing value error when combining positional and optional argument

I'm trying to use the argparse library in python to read in optional and required arguments. So far I'm doing this: import argparse parser = argparse.ArgumentPa

Can Python pickle lambda functions?

I have read in a number of threads that Python pickle/cPickle cannot pickle lambda functions. However the following code works, using Python 2.7.6: import cPic

zipfile header language encoding bit set differently between Python2 and Python3

I would like this code to work the same when run with Python 2 or Python 3 from zipfile import ZipFile, ZipInfo with ZipFile("out.zip", 'w') as zf: conten

[Errno 10054], selenium chromedriver crashing each time

Every time I open up Chrome driver in my python script, it says "chromedriver.exe has stopped working" and crashes my script with the error: [Errno 10054] An ex

Cmake is not able to find Python-libraries

Getting this error: sudo: unable to resolve host coderw@ll -- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) CMake Error at /usr/s