Questions tagged [python-2.7]

Python 2.7 is the last major version in the 2.x series. Do not use this tag simply to convey the version of Python you're using, unless the question concerns an issue specific to Python 2.7. Use the more generic [python] tag.

0
votes
1answer
17 views

Is there a way to specify which Unicode format is used in unicode encoding in python 2.7?

so I'd like to encode some values in Unicode in my python 2.7 script. I'd like to know if I can specify which type of Unicode to use, i.e UTF-8 vs UTF-32. Apart from that are there any limitations ...
0
votes
0answers
6 views

Importing Modules from great-grand-parent directory

I was trying to import great grand parent module say 'A' to a module say 'D'. Here is the Directory/Module heirarchy. A / subA.py B / C/ D / subd.py I want to ...
0
votes
0answers
20 views

Python2 raises exception when using sorted, but python3 doesnot

I have a flask application which was deployed to IBM Bluemix Cloud (which runs on Python 2.7). The application was developed using Python 3 and was made backwards compatible using pasteurize command. ...
0
votes
1answer
25 views

cv2.imshow() function does not show the image if user input is taken, but works otherwise

I'm writing a code to generate user-defined grids on a 500x500 white image. The program should request the user for input on grid size and draw vertical and horizontal lines accordingly and finally ...
1
vote
1answer
13 views

How to open a Tkinter askopenfilename dialog compatible with Python 2 and Python 3

I'm trying to write a simple Python Tkinter file chooser that is compatible both with Python2.7 and Python3.x Python3 Version from tkinter import Tk from tkinter.filedialog import askopenfilename ...
0
votes
0answers
7 views

setting null value for missing keys in JSON to csv

I come across in JSON object that in some records key "score" exists and in some records it does not exists. while converting i need to set the default value for the missing key for that particular ...
1
vote
1answer
10 views

How to fix 'needs more than one value to unpack' error

I am trying to convert RLE to ASCII using this decode structure, however when i try to use it, it always gives me an unpacking error. I have tried adding different data types and adding other ...
0
votes
0answers
7 views

QPython requests SSL error- no available ciphers

Ive been trying to use requests.get for sometime now but I keep getting this error on Qpython HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by SSLError( ...
0
votes
0answers
18 views

The order of dictionary formed in $project of aggregate pipeline, changes while fetching in pymongo

I am facing issue in lookup in MongoDB query which is stored and called using pymongo3.3. There is an ID column in lookup collection which is dictionary. I am creating this LookupID column in project, ...
-2
votes
0answers
11 views

How to run spark-submit in python web app

I am creating a python web application in which i want to run below spark-submit command. ./bin/spark-submit --class "com.ibm.hil.spark.KOLGoldenGen" ./lib/runprocess.jar hdfs://mn-002.south:8020/...
-2
votes
3answers
29 views

subtraction and multiplication column wise

i need to do subtraction and multiplication columns. as per the below format. df1 A B C D E 10 11 13 12 15 11 13 10 15 13 there can be 'n' number of columns. formula - ...
0
votes
0answers
16 views

Output json to xls/csv from lambda to S3

I am trying to convert JSON to excel/CSV and write it to S3 I have a Lambda(python) function. In this Lambda I'm parsing the JSON response of a boto method and extracting a specific set of values and ...
0
votes
1answer
11 views

Attribute error in simpledialog module in Python 2

I have to create popup dialog box which contains text field using tkinter module in Python 2(not Python 3). My other program has many Python2 modules(I have written whole code in Python 2) and so I ...
-1
votes
0answers
12 views

If Statement Inside Nested For Loop

The If statement inside my nested for loop is not executing. Instead, the code essentially ignores it and prints all possible combinations of x_1, x_2, x_3, x_4, x_5, x_6, and x_7 instead of the ones ...
2
votes
1answer
44 views

<bytes> to escaped <str> Python 3

Currently, I have Python 2.7 code that receives <str> objects over a socket connection. All across the code we use <str> objects, comparisons, etc. In an effort to convert to Python 3, I'...
0
votes
1answer
11 views

What does ''HmacAuthV1Handler' object has no attribute 'presign'' mean?

I want to use boto2 (2.49) to create a presigned url that uses Sign v4. Here is my function: c = S3Connection(access_key, secret_key) return c.generate_url_sigv4( expires_in=long(...
0
votes
1answer
9 views

What is the standalone SVC line in sklearn.SVC doing?

In SKLEARN for SVC, there is a part of the code that I don't quite understand its purpose. I understand the idea of passing parameters to SVC when creating a classifier. But the line I am curious ...
0
votes
0answers
18 views

How to write filters for collections with sub-fields

I have a collection that have sub fields. The following is the format of one item of the collection: {u'_id': ObjectId('5d06e596f7c5606c5225458a'), u'msg': {u'date': u'2019-06-16 08:56:00', .....
0
votes
0answers
15 views

What is wrong in this code (generate presign url for putting object to s3) that caused SignatureDoesNotMatch?

I have based my code on this resource here: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html#sig-v4-examples-get-auth-header I am not able to use boto3 directly ...
0
votes
0answers
17 views

How to convert “re.search(pattern, match_string, re.L)” to python 2 and python 3 compatible codes?

This is the original Python2 code: def _MatchOrDefault(pattern, match_string, default=None, flag=re.L): match = re.search(pattern, match_string, flag) But in Python3 it will complain "ValueError: ...
0
votes
1answer
26 views

How do I pass arguments to a callback that is bound to an object on a tkinter canvas?

I am making a tic-tac-toe game, and when you hit the pause button, (not actually a button, just a rectangle with 2 lines that look like a pause symbol on it that when clicked on, generates a callback),...
0
votes
0answers
10 views

Polygons on created surfaces

I am trying to draw an arrow on a new surface so i can then rotate it, but when I draw it on the new surface I have created, it doesn't show up. The icon shows up when it is put on the game_display ...
0
votes
0answers
17 views

Create next and previous button sliding layout by Tkinter

I want to create a simple GUI in python with Tkinter. I have searched lots of links from stackoverflow based on which I am able to come up with the following code. But, the buttons are not in the ...
0
votes
2answers
25 views

Is there a way to rename multiple df columns in Python?

I'm trying to rename multiple columns in a dataframe to certain dates with Python. Currently, the columns are as such: 2016-04, 2016-05, 2016-06.... I would like the columns to read: April2016, ...
0
votes
0answers
6 views

escaping html characters in message before logging

I'm using python's logging module in my application for debugging. I wanted to visualise them as a webpage rather than a text file. So I'm using the Formatter with the following format formatter = ...
1
vote
1answer
26 views

if condition in rows and columns recursive

Issue in applying if conditions in Rows and columns of 2 different dataframes. df1 X1 X2 X3 X4 X5 10 12 8 4 6 df2 class MARKS class_1 8 class_2 6 class_3 9 class_4 ...
0
votes
0answers
22 views

Error: ModuleNotFoundError: No module named 'email.FeedParser'

I am getting Error: ModuleNotFoundError: No module named 'email.FeedParser' when trying to import the following Python libraries: from googleapiclient import discovery from httplib2 import Http from ...
0
votes
0answers
14 views

Unable to lunch Multiple Streaming Pipeline ( N to N Pipeline) Dynamically (Using Runtime Value Provider) in Single Dataflow Job in Python

I am trying to launch a Streaming Dataflow Job which contains n number of pipelines. Based on configured topic and corresponding BQ table for each Topic i want to launch a Pipeline inside a one ...
0
votes
0answers
8 views

Numpy - ImportError: cannot import name _distributor_init while running a SOFA scene controller

I am working with a python scene in sofa framework (www.sofa-framework.org) and I am using spyder IDE to write python scenes. Normally, when I import numpy in Spyder console, it works properly. But ...
0
votes
0answers
33 views

awk unable to escape forward slash

i am getting out certain matched column using awk, but when i am giving variable as "Lag 1:1008:3622" it is working as expected but when i given variable "Port 1/1/3.101" it gives me error (^ ...
0
votes
1answer
5 views

Why different error when using different network connection to put a file to a s3 bucket with Sign v4?

Here are my code: First the driver script #!/usr/bin/env python import os import sys from gen_url import sign import requests import uuid def upload_me(file_path, key=None, secret=None): ...
0
votes
0answers
23 views

How can I insert predefined value in a particular column of big query table?

I want to write one small python utility job which will load data from 2 type of files(say one is "SourceA", another is "SourceB") present in GCS bucket. Both csv files have columns in same numbers, ...
1
vote
0answers
17 views

How to set cookies in get requests headers in python

I am trying to do a GET request call to a local internal portal to fetch data from the portal. I am able to do it successfully using the below code. But i am hard coding the 'cookie' parameter in the ...
1
vote
1answer
33 views

_tds.InterfaceError when trying to connect to Azure Data Warehouse through Python 2.7 and ctds

I'm trying to connect a python 2.7 script to Azure SQL Data Warehouse. The coding part is done and the test cases work in our development environment. We're are coding in Python 2.7 in MacOS X and ...
0
votes
1answer
25 views

Why does os.listdir return an incorrect result?

I'm trying to print out the full paths of all of the members of a directory, but the results are not correct. import sys import os from os.path import abspath test_directory = abspath(r'D:\Python\...
0
votes
0answers
4 views

Pyshark is causing the system to freeze after a few iterations

I am trying to create a sniffer script that sniffs the network for the desired duration and saves pcap file and repeats the process again, But after a few iterations the system is freezing. from ...
0
votes
0answers
12 views

flake8 e999 on using fstrings in python2 (with future_fstrings)

I'm using fstrings in python2 after pip install future-fstrings like the following: # -*- coding: future_fstrings -*- class A(object): def __init__(self, **kw): self.__dict__.update(**kw) ...
0
votes
0answers
13 views

Unable to install package in python 2.7

I have a project build on python 2.7 and can't install any package got SSL error pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
0
votes
3answers
24 views

Aggregate and Convert categorical data to numbers

I have a data frame df_train which has a column sub_division. The values in the column is look like below ABC_commercial, ABC_Private, Test ROM DIV, ROM DIV, TEST SEC R&OM I am trying to 1. ...
0
votes
0answers
37 views

Python - Save A PDF file into Disk

I have the code below which creates a pdf file in memory. pdf = pytesseract.image_to_pdf_or_hocr(self.main_window.filename, extension='pdf') I want to save that pdf file in disk so that I can view ...
1
vote
1answer
24 views

Is there a adaptable algorithm(or code) for multiple parameters optimizatin in python?

I'm making a multiple parameters optimization tool for a simulator in python. I have 7 parameters and with changing the parameters, the 5 result items change. (each parameter has different boundary.) ...
0
votes
0answers
11 views

'FilterExpression' object has no attribute 'value'

I am migrating from Django 1.8.17 to 1.11.21. I re-installed all compatible packages and did required code changes. But it is still giving "'FilterExpression' object has no attribute 'value'" error ...
0
votes
2answers
35 views

How do input more than one word for translation in Python?

I'm trying to make a silly translator game as practice. I'm replacing "Ben" with "Idiot" but it only works when the only word I input is "Ben". If I input "Hello, Ben" then the console prints out a ...
0
votes
0answers
10 views

How can I get rid of “set” from my dictionary?

In order to set values in a dictionary I use d = {} for i in df['name'].unique(): d[i] = [{df['value1'][j]} for j in df[df['name']==i].index] The results of running the code {'key1': [set([v1]...
1
vote
0answers
10 views

Stuck in my factoring program which is confusing [duplicate]

I had this program which I have been having a hard time with. It is a program to find a factor and I am stuck on the edge I wanted the program to find factors and after it finds a factor it will show ...
0
votes
2answers
43 views

BS4 cant find text

I am trying to print this text https://i.imgur.com/SLl1URt.png I used "soup.find_all("p", class_="review")" and tried to use .getText or check inside .contents but none of them worked web link https:/...
-1
votes
0answers
22 views

IOError: [Errno 32] Broken pipe with flask web and bootstrap buttons

Recently i have a problem with my flask webserver, the bootstraps buttons not working anymore. I'm not going to share my script because there is not an error with my script and i have use it for a ...
0
votes
1answer
15 views

How to create dictionary from different dataframes with different lenght and commun column?

I need to create a dictionary from 2 dataframes, DF1 : A C D E 10.12.13.16 604 2345 4572 10.12.13.16 3300 3456 5664 10.24.35.14 200 9753 75498 10....
0
votes
0answers
12 views

Print field in QWEB template HEADER report

Hello I am trying to print in the header of a report the fields of another module different from the default (res_company), the idea is that for each type of procedure the field cm_cod_proc can be ...
0
votes
1answer
23 views

instead of getting a color i get this [31mHello World !!![0m using termcolor and colored

I tried using different methods, the results are the same in cmd and poweshell however i couldnt get it to show the color. The code i used: from termcolor import * print(colored('Hello World !!!', "...