python-2.6

How to install pip with python 2.6 on Windows

核能气质少年 提交于 2019-12-01 18:53:35
问题 Im attempting to install pip with python 2.6 on my dev machine to try to match a deployment environment that also uses python 2.6. Python 2.6 is installed OK. I've tried installing pip using get-pip.py as outlined here https://pip.pypa.io/en/stable/installing/ with the version of the get-pip.py script from https://bootstrap.pypa.io/2.6/get-pip.py However it fails with the following: C:\users\me> python get-pip.py DEPRECATION: Python 2.6 is no longer supported by the Python core team, please

No module named zlib found

坚强是说给别人听的谎言 提交于 2019-12-01 06:07:11
I download python2.6.6 source form http://www.python.org/getit/releases/2.6.6/ After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below error Failed to find the necessary bits to build these modules: _bsddb _curses _curses_panel _hashlib _sqlite3 _ssl _tkinter bsddb185 bz2 dbm dl gdbm imageop linuxaudiodev ossaudiodev readline sunaudiodev zlib To find the necessary bits, look in setup.py in detect_modules() for the

Download a file from https with authentication

六月ゝ 毕业季﹏ 提交于 2019-12-01 05:53:47
I have a Python 2.6 script that downloades a file from a web server. I want this this script to pass a username and password(for authenrication before fetching the file) and I am passing them as part of the url as follows: import urllib2 response = urllib2.urlopen("http://'user1':'password'@server_name/file") However, I am getting syntax error in this case. Is this the correct way to go about it? I am pretty new to Python and coding in general. Can anybody help me out? Thanks! I suppose you are trying to pass through a Basic Authentication. In this case, you can handle it this way: import

No module named zlib found

余生长醉 提交于 2019-12-01 03:38:10
问题 I download python2.6.6 source form http://www.python.org/getit/releases/2.6.6/ After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below error Failed to find the necessary bits to build these modules: _bsddb _curses _curses_panel _hashlib _sqlite3 _ssl _tkinter bsddb185 bz2 dbm dl gdbm imageop linuxaudiodev

ElementTree's iter() equivalent in Python2.6

爷,独闯天下 提交于 2019-12-01 03:04:27
I have this code with ElementTree that works well with Python 2.7. I needed to get all the nodes with the name "A" under "X/Y" node. from xml.etree.ElementTree import ElementTree verboseNode = topNode.find("X/Y") nodes = list(verboseNode.iter("A")) However, when I tried to run it with Python 2.6, I got this error. ionCalculateSkewConstraint.py", line 303, in getNodesWithAttribute nodes = list(startNode.iter(nodeName)) AttributeError: _ElementInterface instance has no attribute 'iter' It looks like that Python 2.6 ElementTree's node doesn't have the iter(). How can I implement the iter() with

Creating dictionary of dictionaries in python 2.6

天大地大妈咪最大 提交于 2019-12-01 01:16:12
I have a line of code in python2.7 that generates a dictionary of empty dictionaries: values=[0,1,2,4,5,8] value_dicts={x:{} for x in values} which throws a syntax error when run on python2.6. I can do the same thing using a for loop: values_dicts={} values=[0,1,2,4,5,8] for value in values : values_dicts[value]={} values_dicts Out[25]: {0: {}, 1: {}, 2: {}, 4: {}, 5: {}, 8: {}} But that seems silly. Why does the list comprehension (in the first block) not work in python2.6? You can use the dict() constructor: value_dicts = dict((x, {}) for x in values) This uses a generator expression that

Extract time from datetime and determine if time (not date) falls within range?

会有一股神秘感。 提交于 2019-11-30 17:13:05
The problem is that I want it to ignore the date and only factor in the time. Here is what I have: import time from time import mktime from datetime import datetime def getTimeCat(Datetime): # extract time categories str_time = datetime.strptime(Datetime, "%m/%j/%y %H:%M") ts = datetime.fromtimestamp(mktime(str_time)) # --> Morning = 0400-1000 mornStart = datetime.time(4, 0, 1) mornEnd = datetime.time(10, 0, 0) # --> Midday = 1000-1600 midStart = datetime.time(10, 0, 1) midEnd = datetime.time(16, 0, 0) # --> Evening = 1600-2200 eveStart = datetime.time(16, 0, 1) eveEnd = datetime.time(22, 0, 0

python pip package install fails , dllwrap error after 'fixing': “unable to find vcvarsall.bat”

前提是你 提交于 2019-11-30 16:04:43
问题 I can't find this in the archives. Is there something not right with mingw/msys? [I need to get vcvarsall.bat fixed, so I can install other packages.] Failure to install python package 'twisted' using pip.exe. I have python2.6 and mingw/msys installed. %PATH% includes C:\MinGW\ and C:\MinGW\mingw32\bin first: pip.exe install twisted fails by saying error: Unable to find vcvarsall.bat I create file G:\Programs (x86)\Python 2.6\Lib\distutils\distutils.cfg , which contains: [build] compiler

How to stop Python parse_qs from parsing single values into lists?

我只是一个虾纸丫 提交于 2019-11-30 12:39:23
问题 In python 2.6, the following code: import urlparse qsdata = "test=test&test2=test2&test2=test3" qs = urlparse.parse_qs(qsdata) print qs Gives the following output: {'test': ['test'], 'test2': ['test2', 'test3']} Which means that even though there is only one value for test, it is still being parsed into a list. Is there a way to ensure that if there's only one value, it is not parsed into a list, so that the result would look like this? {'test': 'test', 'test2': ['test2', 'test3']} 回答1: You

inspect.getmembers in order?

醉酒当歌 提交于 2019-11-30 11:17:15
inspect.getmembers(object[, predicate]) Return all the members of an object in a list of (name, value) pairs sorted by name. I want to use this method, but I don't want the members to be sorted. I want them returned in the same order they were defined. Is there an alternative to this method? Use case: Creating a form like so: class RegisterForm(Form): username = Field(model_field='username', filters=validators.minlength(3)) password1 = Field(model_field='password', widget=widgets.PasswordInput) password2 = Field(widget=widgets.PasswordInput) first_name = Field(model_field='first_name') last