Calculating a total cost in Python

I'm trying to create a trip planner in python, but after I defined all the functions I'm not able to call and calculate them in the last function tripCost(). In tripCost, I want to put the days...

ImportError: numpy.core.multiarray failed to import

I'm trying to run this program import cv2 import time cv.NamedWindow("camera", 1) capture = cv.CaptureFromCAM(0) while True: img = cv.QueryFrame(capture) cv.ShowImage("camera", img) ...

Popping all items from Python list

I'm wondering if there is a way to "pop all" items from a list in Python? It can be done in a few lines of code, but the operation seems so simple I just assume there has to be a better way than...

Change all hex colors values to rgb

I have around 50 css files with more than 200 color entries. I need to convert all hex colors values to rgb. Is there any tool which can my task easy else I have to open every css file and do it...

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

... soup = BeautifulSoup(html, "lxml") File "/Library/Python/2.7/site-packages/bs4/__init__.py", line 152, in __init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with...

Failed to build gem native extensions of jquery-rails after installing Python 2.7

Using: Ruby: 2.1.1 Rails: 4 OS: Debian Wheezy Short problem story: I installed Python 2.7 and now my bundle install won't succeed anymore. It got stuck at: Using jquery-rails...

Python datetime.utcnow() returning incorrect datetime

datetime.utcnow() This call is returning an incorrect datetime, delayed from UTC/GMT by 1 hour (check in: http://www.worldtimeserver.com/current_time_in_UTC.asp). Is it working like it should...

How to pass file pointer in dll routines using ctypes in python

I'm accessing one function from dll which need file pointer (char *filename). How can I pass it through python? handle = cdll.dsp p = open("signal.txt", "r") handle.filter(p)

Slicing a Python OrderedDict

In my code I frequently need to take a subset range of keys+values from a Python OrderedDict (from collections package). Slicing doesn't work (throws TypeError: unhashable type) and the...

Odoo - prevent button from closing wizard

I have a transient model that serves as a dialog. In my form view I have a button like this: <footer states="partnerId"> <button name="check_tax_id" string="Tovább"...

How can I play a Spotify audio track with Python?

I would like to know if it's possible to play songs from Spotify with Python (version 2.7 if possible) and how.

How to convert CRLF to LF on a Windows machine in Python

So I got those template, they are all ending in LF and I can fill some terms inside with format and still get LF files by opening with "wb". Those templates are used in a deployment script on a...

Implement packing/unpacking in an object

I have a class that only contains attributes and I would like packing/unpacking to work on it. What collections.abc should I implement to get this behaviour? class Item(object): def...

Cannot find plot function in GPy library (python)

I am using the GPy library in Python 2.7 to perform Gaussian Process regressions. I started by following the tutorial notebooks provided in the GitHub page. Sample code : import numpy as np import...

it failed when tried to get host name using python

socket.getfqdn() and the result is ok,return sjs_88_78 and then socket.gethostbyname('sjs_88_78') it will socket.gaierror: [Errno -2] Name or service not known is it env issue?how to fix...

Using scipy.interpolate.interpn to interpolate a N-Dimensional array

Suppose I have data that depends on 4 variables: a, b, c and d. I want interpolate to return a 2D array which corresponds to a single value of a and b, and an array of values for c and d. However,...

Django AttributeError: 'User' object has no attribute 'set_password' but user is not override

I have the following error: AttributeError: 'User' object has no attribute 'set_password' The problem is I didn't override the class User: My model.py: class User(models.Model): username =...

Static CSS file not loading in Django framework

I'm running on localhost but stylesheet isn't working Here is my project setup: -main -main -home -templates -home -index.html -static -css ...

How to print dictionary values line by line in Python?

This is my dictionary {'www.pic2fly.com/Weather+Of+Bahawalpur.html': ['https://tse1.mm.bing.net/th? id=OIP.RsEykDoK1xxg2zivHYW7WwEsC5&pid=Api'], 'panoramio.com/photo/84118355': ...

How I can convert file with any format to text format using Python 3.6?

I am trying to have a converter that can convert any file of any format to text, so that processing becomes easier to me. I have used the Python textract library. Here is the documentation: ...

How To Run Selenium With Chrome In Docker

I installed google-chrome in a Docker, but when I run my Python 2 script of Selenium, it failed like this: [email protected]:/topology-editor/test$ python test.py Traceback (most recent call...

Save and load kernel in GPy in a sparse gaussian process regression

I built and optimized a Sparse Gaussian Process Regression model using the GPy library. The documentation recommends to save the model as follow: To save a model it is best to save the...

Python - asynchronous logging

I need to log plenty of data while running my system code. What logging packages I can use to have an efficient, asynchronous logging? Is the standard Python logging package...

Getting [Errno 110] 'Connection timed out' when trying to do get requests in python

I am able to access the below "URL" mentioned in code manually in firefox browser and see the json response as : { "version" : "1.0", "email_address" : "[email protected]" } But when I am...

How can I control the alignment of y axes in multiple subplots with pyqtgraph when the tick labels have different lengths?

I am using pyqtgraph to make a plot with a few subplots and shared X axes. However, when the tick labels have different lengths, the Y axes do not line up with each other. How can I make the plots...

Keyboard input over SSH to the raspberry pi3 with pynput function in python

I'm trying to control a small car toy using the raspberry pi 3 the SSH from my laptop. The challenge I'm facing is, when I'm directly connected on RPi (mouse, keyboard and monitor plugged to the...

RuntimeError: Attempting to deserialize object on a CUDA device

I encounter a RunTimeError while I am trying to run the code in my machine's CPU instead of GPU. The code is originally from this GitHub project - IBD: Interpretable Basis Decomposition for Visual...

How to tell futurize (python-future) to not touch a specific line?

I'm trying to convert Python 2.7 codebase to 3.x using python-future. Sometimes I need to keep a small bit of Python-2-specific code intact, until the migration is complete. For example, import...

Google Foobar challenge Minion Work Assignments

I've seen a lot of these google foobar challenges and really didn't think I would be invited. I want to ask about the first question. All in all the requirement is this: '''Write a function called...

How to install Boost.Python using homebrew (on OSX)?

I'm trying to install Robot Operating System (ROS) Melodic on my mac (macOS 11.5.1). While compiling cv_bridge package, the compiler spit out an error related to the Boost.Python: $...