Questions tagged [python-2.7]

Python 2.7 is the last major version in the 2.x series, and is no longer maintained since January 1st 2020. Use the generic [python] tag on all Python questions. Do not add this tag simply to convey the version of Python you're using, unless the question concerns an issue specific to Python 2.7.

python-2.7
Filter by
Sorted by
Tagged with
0 votes
1 answer
555 views

jinja2 yaml python hash issue

I have a problem with jinja generate.py: from jinja2 import Template import yaml import sys import os.path #Parse the YAML file and produce a Python dict. yaml_vars = yaml.load(open('...
Stepan's user avatar
  • 23
0 votes
1 answer
86 views

Python processing nested json

I am feeding the following data to my python script as an argument: source=Blabla|| name=TEST Error in Log - Error: 3345|| item_value={ "Error": 3345, "Message": "Some error occurred", "Status": 1 } ...
Iokanaan Iokan's user avatar
0 votes
2 answers
3k views

Python 2.7 - grammar-check 1.3.1 library: HTTP Error 400: Bad Request

I am trying to use the grammar-check 1.3.1 library for Python I have installed it using the pip commands $ pip install --upgrade 3to2 $ pip install --upgrade language-check I also unzipped the ...
EstevaoLuis's user avatar
  • 2,522
0 votes
2 answers
343 views

Create Sub Folders within a specific Sub Folder

So I have a directory being created with todays date and a user choice of three integers. Within this directory I have a number of sub folders being created that are named ARI,Ale, Cdl, MXF, Reports ...
Jonathan Petts's user avatar
0 votes
1 answer
4k views

write into excel file without overwriting old content with openpyxl

I need to copy data from a text file to an excel file, but without overwriting the old data. my code: import os,sys from openpyxl import Workbook from openpyxl.compat import range wb = Workbook() ...
ismael bouzoubaa's user avatar
0 votes
1 answer
76 views

how to efficienlty do dataframe shift with a jump

I have 60 log files that I am analysis. From those files I created the dataframe state_n_ev_mat. Its size is [2083656 rows x 8 columns]. Below you can see the first 50 rows of state_n_ev_mat. Where, ...
Arraval's user avatar
  • 1,130
1 vote
0 answers
1k views

Matplotlib copy/duplicate a 3D figure?

I've tried to find a way to copy a 3D figure in matplotlib but I didn't find a solution which is appropriate in my case. From these posts How do I reuse plots in matplotlib? and How to combine ...
romain.bqt4's user avatar
0 votes
2 answers
15k views

Pip install with pip in requirements

I made a package (called "my_package" in the following) that needs minimal versions of pip and setuptools to install. Is it possible to update them during the "pip install my_package" (but not by ...
StormRider's user avatar
0 votes
2 answers
2k views

Run scons on Windows 10 environment with Python 2.7 and Python 3

How can I run scons on Windows 10 when Python 3.6.1 and Python 2.7.13 is installed? When typing python into my command window I get the following output: Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:...
Vertexwahn's user avatar
  • 7,719
3 votes
0 answers
832 views

Getting SHA1 checksum of multiple files Python

I am trying to get SHA1 checksum of multiple files. I tried solution form this thread Generating one MD5/SHA1 checksum of multiple files in Python So I put together following: MainScene = "C:/...
user2033139's user avatar
-3 votes
3 answers
525 views

python ascii values split into list to convert into string

string of ascii values are given how can i split these ascii values and convert to string given ascii values:87101108991111091013211611132112121116104111110 How to separate above input in list like ...
saivinay manapuram's user avatar
3 votes
3 answers
118 views

Zip in python does not work properly with lists

Here is what I tried: >>> d array([ 0.71428573, 0.69230771, 0.69999999], dtype=float32) >>> f [('name', 999), ('ddd', 33), ('mm', 112)] >>> for n1,s1,normal in zip(d,f):...
Jaffer Wilson's user avatar
0 votes
1 answer
3k views

TypeError: unbound method _get_tests() must be called with Loader instance as first argument (got nothing instead)

In the following code, "_get_classes" method works fine but "_get_tests" throws the above mentioned error. What am I doing wrong here? def my_func(): x = Loader._get_classes("test","number") # ...
Aditya's user avatar
  • 561
0 votes
1 answer
124 views

Get percentage unique numbers generated by random generator

I am using random generator in my python code. I want to get the percentage of unique random numbers generated over a huge range like from random(0:10^8).I need to generate 10^12 numbers What could be ...
NGB's user avatar
  • 430
0 votes
4 answers
62 views

How to replace all character like (--) in vector data 0 using python

Hi I have 3 columns of data in myfile.dat file. They are ordered like below. 234 -642 20.20 233 -640 20.40 233.4 -- 20.60 -- -646 20.80 -- -642 21.00 234 -- 21.20 ...
Poka's user avatar
  • 387
0 votes
1 answer
2k views

Does tensorflow support python 2.7 on windows 10?

OS:Windows 10 Python ver.:Python 2.7.13 tensorflow ver.:1.0.1 CUDA:v8.0 cudnn:v5.1 I have already set my CUDA and cudnn well. cudnn64_5.dll is in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\...
Chuck Liu's user avatar
  • 101
4 votes
4 answers
1k views

Close file using with operator in Python

I have a question regarding file closing in python with operator import os with os.popen('ls') as f: print f.read() raise IOError print f print f As you can see ...
Arun's user avatar
  • 1,159
6 votes
1 answer
645 views

Optimize scipy nearest neighbor search

I am trying to find all the nearest neighbors which are within 1 KM radius. Here is my script to construct tree and search the nearest points, from pysal.cg.kdtree import KDTree def construct_tree(s)...
ds_user's user avatar
  • 2,159
4 votes
6 answers
3k views

converting a dictionary to another one [duplicate]

I have a dictionary, the keys are integer values and the values are a list of strings. I want to make it vice versa, the string become key and integers become values. Like: first design: {1:["a"], ...
B bonita's user avatar
  • 181
0 votes
2 answers
844 views

Trouble installing a python package with conda

I'm trying to install a Python package (Pyclone) using anaconda (the latest release of miniconda, specifically) using the following suggested script: conda install pyclone -c aroth85 And I get the ...
user3593717's user avatar
0 votes
2 answers
72 views

How do I let Python see what Terminal outputs when I enter a command?

I want to run a program on Python on macOS Sierra that checks Terminal for its outputs after I automatically enter a command on it. For example, I would write in Terminal: $ pwd and then Terminal ...
Joseph Odeh's user avatar
2 votes
1 answer
61 views

How to parse arrays which vary between data sets?

I have the following data set: File1: <Molecular Orbital Primitive Coefficients> <MO Number> 1 </MO Number> 4.224609607748e+00 4.085857782359e+00 1.273383604708e+00 -6....
pennypeat's user avatar
0 votes
2 answers
1k views

Scrapy get type/info about immediate next sibling

I am extracting information from a site with html that looks like: <h2> <span class="mw-headline" id="Cast">Cast</span></h2> <ul><li> <a href="/Shota_Sometani" ...
waylonion's user avatar
  • 6,906
1 vote
0 answers
314 views

Create a Gmail account in Django using Python?

I'm working on a Django project and wanted its users to have the ability to create a Gmail account directly through our site. Is anyone familiar with a way to do so? If not, I was thinking of ...
user avatar
0 votes
1 answer
70 views

Text processing using python

This is the sample file, I would like to check if "field5" exists in file, if exists check if 67890 exits, if exists then print corresponding values for "field5" sample output: 112 START field1 ...
Maddy M's user avatar
  • 23
-1 votes
1 answer
60 views

Validating the date formats using the variables

I need some help with my code. I have got a problem with setting up the date formats. I'm using the value int(next_day) + 1 so I could add the day to the next day date. Example: from this 01/07/2017 ...
user avatar
0 votes
1 answer
20 views

New function doesn't accept returned values from other function

I'm reading from a CSV file and created a function that separates the players from that file into 2 lists: experienced and fresh players. Then, I tried to create another function that would print the ...
dresurieta's user avatar
2 votes
0 answers
84 views

How to read an image url with Unicode characters in Python 2 with urllib?

Requirements: Python 2.7 and no external libraries like Requests or BeautifulSoup :( I get the error in the traceback from retrieveUrl when I call this url: u'http://%E7%9F%A5%E3%81%A3%E5%BE%97%E8%A2%...
user3704512's user avatar
4 votes
0 answers
342 views

transport error from firebase admin when try to validate jwt

the final line in this Python code: from firebase_admin import credentials, initialize_app from firebase_admin import auth as firebaseAuth _cred = credentials.Certificate('common/auth/...
Dewey's user avatar
  • 766
0 votes
3 answers
95 views

Collecting Relational Data and Adding to a Database Periodically with Python

I have a project that : fetches data from active directory fetches data from different services based on active directory data aggregates data about 50000 row have to be added to database in every ...
jojo's user avatar
  • 137
0 votes
1 answer
692 views

AttributeError module 'Pyro4' has no attribute 'expose' while running gensim distributed LSI

So I am trying to run the demo from gensim for distributed LSI (You can find it here) Yet whenever I run the code I get the error AttributeError: module 'Pyro4' has no attribute 'expose' I have ...
A.Shoman's user avatar
  • 2,969
2 votes
2 answers
1k views

read text file content with python at zapier

I have problems getting the content of a txt-file into a Zapier object using https://zapier.com/help/code-python/. Here is the code I am using: with open('file', 'r') as content_file: content = ...
Robin Alexander's user avatar
1 vote
1 answer
1k views

Getting input from a browser - python + forms

Working through LPTHW exercise 51 and hit a wall. Trying to get some basic user input through a browser and then display it. Code is as follows - first python: import web urls = ( '/', 'Index' )...
sjannette's user avatar
0 votes
0 answers
86 views

Modules are installed but imports still throw errors (pandas)

I am having trouble importing modules in python 2.7.13. I run the python script and this is the following error. Traceback (most recent call last): File "server.py", line 3, in <module> ...
LeggoMaEggo's user avatar
0 votes
1 answer
57 views

flask/MongoDB error on local server using raspberry pi3 - raspbian os

i've made a local server using flask and mongoDB which works great on windows, but when i moved my code to the raspberry pi, i've got an error which i couldn't figure out why it occurs. the code im ...
gil's user avatar
  • 2,506
0 votes
1 answer
75 views

Add Weekday as locale’s full name to my programs welcome message

So for a bit of fun I want to add Hello! Happy "Monday"(for example) when my program opens up in Terminal. I have been using the strftime directives for naming my folders that get generated. But I ...
Jonathan Petts's user avatar
0 votes
0 answers
656 views

How to exit a loop? [duplicate]

I'm asking input from the user and wanted to check if he used the right letters to continue, I've wrote this code, but even when I write "y" or "n", it doesn't exit the loop, and I have no idea why: ...
dresurieta's user avatar
11 votes
3 answers
12k views

Lemmatizing Italian sentences for frequency counting

I would like to lemmatize some Italian text in order to perform some frequency counting of words and further investigations on the output of this lemmatized content. I am preferring lemmatizing than ...
TPPZ's user avatar
  • 4,739
2 votes
1 answer
2k views

Communicating Python with android?

I'm working on my Project but here arises a problem that I'm ready with my python script which controls raspberry pi 3 GPIO pins but I don't know how to interact my python script with Android. Someone ...
Akrit Khanna's user avatar
1 vote
1 answer
162 views

Static member initialization in python from static member value of a derived class

Is it possible to initialize a static member of a base class from a static member of a derived class in python (2.7)? Namely, suppose I have a bunch of classes that map the entities stored in a ...
Clonet's user avatar
  • 13
0 votes
1 answer
473 views

python xml fromstring can not decode gbk encoding?

I encoding xml with "gbk": #!/usr/bin/env python # encoding: utf-8 from xml.etree.ElementTree import Element, SubElement, tostring, fromstring, XML, XMLParser root = Element('root') child = ...
roger's user avatar
  • 9,513
2 votes
1 answer
147 views

How to reshape an array of lists?

I have the following array: array([ list(['4.224609607748e+00', '4.085857782359e+00', '1.273383604708e+00', '-6.802974691818e-03']), list(['9.099528133406e-03', '6.867550219273e-03', '5....
pennypeat's user avatar
0 votes
1 answer
141 views

I want to run some code using Sympy. However, it says there is no such module

So when I run my program it says that sympy doesn't exist as a module. However, it is installed (see screenshot). I can run Sympy using a virtual python environment. However, then matplot does not ...
Nicolas Kalousek's user avatar
1 vote
2 answers
3k views

Anaconda conda traceback: UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 1: ordinal not in range(128)

OS: WIN7 64bit Anaconda version: 4.4.0 of Python 2.7 After the installation, I typed "conda" in cmd while it showed the error as below: Traceback (most recent call last): File "D:\Anaconda2\...
xiangyue1993's user avatar
0 votes
3 answers
99 views

Read file txt into list 2 Dimension in Python [closed]

I want to ask something about python here. I'm new in this kind of programming Input : Emma,F,19414 Olivia,F,19246 Ava,F,16237 Output : [['Emma', 'F', '19414'], ['Olivia', 'F', '19246'], ['Ava'...
ANJAY CHANNEL's user avatar
2 votes
1 answer
957 views

Python django foreign key (1048, "Column 'USER_ID' cannot be null")

I have two models, one is UsersModel model, the other one is address_add. I want to create a relation between UsersModel and address_add with USER_ID field. Finally, I created the template and after ...
apodaka's user avatar
  • 33
0 votes
1 answer
123 views

coroutine yield continue to main

I'm trying to use coroutine in order to send data to NATS (nats.io messaging system). When I try to call this code without arguments and for loop it's working perfectly. But when I am adding ...
MIkCode's user avatar
  • 2,755
1 vote
1 answer
624 views

Pulp (Python) Value Error: need more than 1 value to unpack

I'm trying to solve this problem http://www.me.utexas.edu/~jensen/ORMM/models/unit/linear/subunits/workforce/ using PuLP on Python. This is my code: from pulp import * # Create the 'prob' variable ...
plshelp's user avatar
  • 243
0 votes
1 answer
3k views

Python: how to get a parent instance from a child instance

If I have two child classes both inherit from the same parent class class Parent(object): def __init__(self): self.name = 'parent' self.position = 0 class ...
Coco's user avatar
  • 1
1 vote
0 answers
153 views

switch between training dataset and computing accuracy of validation set

I want to train and check accuracy of validation set in this code. I use is_training and tf.QueueBase.from_list to switch between train and compute accuracy. type of datasets are tfrecord. inference ...
vahid mahmoodi's user avatar

1
546 547
548
549 550
1905