Python 2.7 is last major version in the 2.x series. This release contains many of the features that were first released in Python 3.1. Use the more generic [python] tag if your question is not version-specific.

learn more… | top users | synonyms

6
votes
0answers
165 views

How to check which detail of a complex object can not be pickled

Overview I want to serialize my complex objects. It looks simple but every step creates for me a different problem. In the end, other programmers must also be able to create a complex object ...
5
votes
0answers
871 views

OpenCV Python : No drawMatchesknn function

When I tried to use drawMatchesKnn function as mentioned in this tutorial for FLANN feature matching, I get the following error AttributeError: 'module' object has no attribute 'drawMatchesKnn' ...
5
votes
0answers
744 views

f2py with Intel Fortran compiler

I am trying to use f2py to interface my python programs with my Fortran modules. I am on a Win7 platform. I use latest Anaconda 64 (1.7) as a Python+NumPy stack. My Fortran compiler is the latest ...
5
votes
0answers
524 views

numpy fromfile(count = -1) returns array of zeros on Mac OS for huge filesize

I am reading a file using numpy.fromfile: mat1=numpy.fromfile("path/to/file", numpy.uint8, 40000, "") this reads the file as i expect. but when i read the entire file: ...
4
votes
0answers
125 views

Importing EPF file could not complete becasue got incorrect string value error

I have installed mysql 5.5 and mysqldb for python [MySQL-python-1.2.3.win32-py2.7], python version 2.7 also, create new database with charset utf8 and installed from apple itunes.rar and extract it. ...
4
votes
0answers
149 views

Using Numpy on IronPython 64 Bit

Is it possible at all to use numpy on IronPython 64-bit? I've made an attempt to use the packages distributed by Enthought but they do not work. Any suggestions on this? Are there any projects ...
4
votes
0answers
2k views

cv2.imread flags not found

I recently started working with openCV and python and decided to analyze some sample code to get an idea of how things are done. However, the sample code I found, keeps throwing this error: ...
4
votes
0answers
858 views

How to use SPDY from Python2.7?

I am trying to use SPDY from Python 2.7. I found the Python-spdylay library as a wrapper around the C implementation. I realize that some parts of the library are Python 3 only. I would like to ...
4
votes
0answers
87 views

How to implement texturing over a model using pycollada?

I am developing a python script which will be able to generate .DAE (COLLADA) files along with the associated KML files for developing 3D models of buildings. I have the street images of the ...
4
votes
0answers
1k views

const void* pointer in ctypes

If I have a writable buffer, I can use ctypes.c_void_p.from_buffer function to obtain a C pointer to this buffer. How to deal with non-writable buffers, however? How to form a const pointer that I ...
4
votes
0answers
342 views

Compiling Python to a static lib and using pythoncore.lib

I'm trying to build Python 2.7 as a static single .lib file. I've already made the following changes to the Python source code: Change to "Release" mode. Change all DLL projects to Static library ...
3
votes
0answers
54 views

Where do I put assets for my python tests?

I'm new to python. I'm trying to set up tests for my python classes using nose. Where do I put assets for my tests? Ok so lets say I have a class that manipulates an image. I have an image for each ...
3
votes
0answers
54 views

imp.load_source another file than .py , but a .py also exist in that directory

I have this setup : File : a.ext1 a.py a.ext1 loads a.py for some reason, but as an engine I need to load file a.ext1. I can get it working fine in py3, but I cannot get it working in py2. Here ...
3
votes
0answers
60 views

updating python globals from thread

I have a config file that needs reloading occasionally. The reload is called inside a method of a class that's running within a thread. I have tried to do this by using globals() but despite the fact ...
3
votes
0answers
75 views

Encountered an error while setting up a Python environment

I'm developing a web-browser extension, and have found a tool which will allow me to publish the extension for all browsers from a single code-base. The tool is called Open Forge and is developed by ...
3
votes
0answers
81 views

Huge difference in timing between sorting a set vs sorting a list in Python

I was wondering whether I should have my data structure as a set or a list. Mostly I will do set operations, but in the end I will need to sort it. I wondered whether I should first make the set a ...
3
votes
0answers
38 views

How to imitate Python 3's raise … from in Python 2?

Python 3 has the neat try: raise OneException('sorry') except OneException as e: # after a failed attempt of mitigation: raise AnotherException('I give up') from e syntax which allows ...
3
votes
0answers
46 views

Django Oauth Toolkit 2-legged and 3-legged

I have been searching on the internet but haven't been able to find this answer. Basically i want to know if Django Oauth Toolkit supports both 2-legged and 3-legged approach and if so, how do i use ...
3
votes
0answers
40 views

Python C API: ommited variable assignment causes unexceped behaviour

While using python with pyroot (a python interface to a CERN data analysis package named ROOT), I encountered the following strange behaviour: print ROOT.TFile(fname).GetListOfKeys() outputs None ...
3
votes
0answers
145 views

IPython behavior different for .py and .ipy files despite script being “pure” python (custom exception handler hook stops working)

I have written an exception handler that is meant to log all uncaught exceptions in the code before calling the normal python exception hooks. Python and iPython have slightly different ways of doing ...
3
votes
0answers
308 views

Scipy autotest finished with one error

Under Ubuntu 14.04 I installed python 2.76. then scipy as shown here, namely through sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas ...
3
votes
0answers
235 views

Python pandas.read_csv : low_memory and memory_map flags

the function signature for pandas.read_csv gives, among others, the following options: read_csv(filepath_or_buffer, low_memory=True, memory_map=False, iterator=False, chunksize=None, ...) I ...
3
votes
0answers
526 views

pip install on OS X Mavericks fails with error: /usr/local/bin/pip: No such file or directory

I am running the Python 2.7.5 version that came standard with OSX. I have tried to install pip using sudo easy_install pip AND python get-pip.py When I try to install pip I get the following error ...
3
votes
0answers
205 views

setup.py & pip: override one of the dependency's sub-dependency from requirements.txt

I'm currently working on a package and in my requirements.txt, I have a dependency: wikipedia Now, wikipedia 1.3 uses requests-2.2.1 while my package uses 2.3.0 Also, as one would expect, ...
3
votes
0answers
195 views

Scrapy and Webkit keeps freezing

I am using scrapy to crawl some websites with JavaScript. The scraper works fine, but it keeps freezing at random places. I need to kill the script with ctrl+z, but it only freezes when i use this ...
3
votes
0answers
105 views

Using a local module instead of system installed module (Python 2.x.x)

I have a cluster system at work with Python and some modules installed on that system - however I wanted to use the most up to date version of the module - it has several methods not present in older ...
3
votes
0answers
152 views

downloading pygame dependencies with homebrew; config.py file doesn't recognize them

Another tedious pygame install (on osx) question but I've searched far and wide and haven't been able to find an answer to this particular issue. When I run config.py here's my output: Hunting ...
3
votes
0answers
173 views

Saving scikit-learn classifier causes memory error

My machine has 16G RAM and the training program uses memory up to 2.6G. But when I want to save the classifier (trained using sklearn.svm.SVC from a large dataset) as pickle file, it consumes too much ...
3
votes
0answers
102 views

Set IPython Profile for QtInProcessKernelManager

I'm running the IPython 2.0b1 code so that I can use the native QtInProcessKernelManager for embedding an IPython shell inside a Qt app. Following the example in embedded_qtconsole.py I've got ...
3
votes
0answers
124 views

Django ignoring translated strings from third party module

I'm building a website with Django 1.6 and Python 2.7, and translating it into a second language. The Django framework messages, and strings in my own templates and code are all translating fine. I'm ...
3
votes
0answers
55 views

making autogenerated module members visible to PyDev/PyLint static analysis

If I am designing a Python module with dynamically-generated members, is there a way for me to help PyDev/PyLint out to give it some information? (rather than requiring end-users of the module to ...
3
votes
0answers
122 views

Dynamically register functions with Python C-API

I am looking for a way to have a Python C function register other Python C functions in its module. Usually functions are declared statically in the shared library using: Py_InitModule(module_name, ...
3
votes
0answers
420 views
+50

Using mechanize in python does not seem to be working correctly for POST requests. (400 Error)

I am coding an IRC bot in Python in order for my friends and I to buy items from the steam market. It is mostly for fun and to advance my programming skills. I have been able to get the lowest price ...
3
votes
0answers
784 views

Unable to read instance data, giving up error in python boto

I am trying to access amazon s3 using boto library to access common crawl data availble in amazon 'aws-publicdatasets'. i created access config file in ~/.boto [Credentials] aws_access_key_id = "my ...
3
votes
0answers
159 views

How to open a file in a new process everytime irrespective of fileopener

I am using windows 7 64 bit python 2.7 I am opening the file, and monitoring the file changes and then waiting till the opened file is closed. This works well in case of simple notepad file opener. As ...
3
votes
0answers
105 views

dtype mismatch in sklearn on k-means

I am attempting to run the first answer to this question Python Relating k-means cluster to instance however I am getting the following error: Traceback (most recent call last): File "test.py", ...
3
votes
0answers
95 views

In python using matplotlib how to display multiline strings in ax.fmt_xdata

I'm using matplotlib version 1.2.0 and python 2.7 on linux. plot(numpy.arange(10)) ax = gca() ax.fmt_xdata = lambda x: "line1 %d\nline2 %f"%(int(x),x) On linux using the Qt4Agg backend it does ...
3
votes
0answers
155 views

Why am I getting EITHER an UnboundLocalError in reference to pylab.legend, OR a No Such File error?

Ok, I know there are a LOT of questions about UnboundLocalError(s). I've read them, and have attempted to solve my issue, but do not think my error directly stems from a global/local variable issue in ...
3
votes
0answers
246 views

import Error while importing python nltk module in node.js using “python-node” module

I am trying to import python natural language processing toolkit nltk in node.js using node-python mentioned here: https://npmjs.org/package/node-python The commands i am giving are similar as ...
3
votes
0answers
679 views

twisted.internet.error.ConnectionRefusedError: 111: Connection refused

I'm getting the following failure:- Failure: twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 111: Connection refused. I note that the client never asks me ...
3
votes
0answers
252 views

Why does SIGINT sent to Python script kill MySQL connection?

I'm having an issue with sending SIGINT's to python scripts which are connecting to a MySQL database using MySQLdb (mysql-python). The python script runs in an infinite loop, and I want to catch the ...
3
votes
0answers
747 views

Webdriver + PhantomJS just hangs in there

I'm using Selenium Webdriver (in Python) to automate the downloading of thousands of files from a certain website (that can't be webscraped by conventional means like urllib, httplib, etc). My script ...
3
votes
0answers
421 views

How to Install Matplotlib Basemap Module on Windows 7 with WinPython (or any Python stack install)?

I've found that the Basemap (module for matplotlib and Python) binary installer for Windows cannot detect Python on the system when Python is installed as part of a stack install, like Anaconda or ...
3
votes
0answers
633 views

tornado python gives attribute error 'none type object has no attribute'

#!/usr/bin/python27 import tornado import tornado.websocket import tornado.wsgi import motor import json import jsonpickle import uuid from py2neo import neo4j, cypher from tornado.ioloop import ...
3
votes
0answers
256 views

Python mock - reassigning return_value doesn't work

I have a test function (inside a unitttest.TestCase) that looks something like this: @patch('some.list') def test_thing(self, mocklist): # some setup code mocklist.__iter__.return_value = ...
3
votes
0answers
822 views

Sphinx autodoc show-inheritance: How to skip undocumented, intermediate bases?

I have a three-layered class structure like this: class Super(object): """This class is documented.""" class Intermediate(Super): pass class Sub(Intermediate): """This is also ...
3
votes
0answers
1k views

Change Windows Background from Python

Does anyone know a way to change the Windows Desktop Wallpaper with python so that the change is permanent? I have found this code import ctypes SPI_SETDESKWALLPAPER = 20 ...
3
votes
0answers
328 views

Is the latest version of xattr (0.6.4) compatible with the latest stable version of Python (2.7.5)?

I'm asking this question because I'm having problems installing Little Snitch 3.1 on Mac OS X Mountain Lion 10.8.3. Indeed, I'm getting the following error: Error removing quarantine on ...: python ...
3
votes
0answers
101 views

What is the opposite of PyMODINIT_FUNC in Python 2.x C extension modules?

I need to import one of the core modules (datetime) inside my C extension module since I want to return a datetime.date from some functions of my module. It appears that Python C extension modules ...
3
votes
0answers
368 views

Django custom field with sub fields

I was following this articles to have 2 columns per 1 field , so my custom field code is something like this : class GeopositionField(models.Field): description = "A geoposition (latitude and ...