Python is an interpreted, general, high-level programming language. The design emphasizes readability. It is notable for using tabs to indicate block levels. As a dynamic language, it shares many similarities to Ruby, Perl, and Scheme. The language is very popular for scientific computing and ...

learn more… | top users | synonyms

26
votes
5answers
14k views

emacs: how to indent/unindent region of python code by 4 spaces?

I have a region of python code selected in emacs. What are the most efficient ways to indent and unindent every line in it by 4 spaces? Ideally I'd like something that's not context sensitive (eg. ...
24
votes
4answers
62k views

How can I change the default Python version on Snow Leopard?

I recently upgraded my Mac OS X 10.5 Leopard install to 10.6 Snow Leopard, and with that came an upgraded version of Python, 2.6.1 (instead if 2.5.1). Now when I type python in the Terminal i still ...
17
votes
6answers
9k views

How to simulate slow internet connection

I currently deploy with GAE (google app engine) and I try to implement some AJAX validation. So I got a couple text-fields and "spinners" (ajax loaders) which should be displayed when an AJAX request ...
15
votes
6answers
14k views

installing wxpython via pip or easy_install

I am running into some problems installing wxpython using pip. Here is my current output: [myuserid]% sudo pip install wxpython Downloading/unpacking wxpython Downloading ...
14
votes
6answers
13k views

How to install matplotlib on OS X?

I want to install matplotlib on OS X. If possible, using homebrew. I installed Python 2.7.1 using brew install python, I modified my path to use it I installed pip using brew install pip I installed ...
14
votes
2answers
13k views

easy_install will not connect through proxy

I'm running Ubuntu Server 10.04 64-bit under VirtualBox, and it seems that everything except easy_install and pip can connect to the Internet. I have set and exported the http_proxy environment ...
13
votes
2answers
3k views

How can I use the Homebrew Python with Homebrew MacVim on Mountain Lion?

I originally asked and answered this question: How can I use the Homebrew Python version with Homebrew MacVim? These instructions worked on Snow Leopard using Xcode 4.0.1 and associated developer ...
13
votes
3answers
43k views

How to globally modify the default PYTHONPATH (sys.path)?

On a Ubuntu (10.10) system, I have a Python package that installs itself into /usr/local/lib/python2.6/site-packages/. This isn't contained in the default path (sys.path). How do I add this directory ...
12
votes
6answers
2k views

What is the best method to remove duplicate image files from your computer

I have a lot of duplicate image files on my Windows computer, in different subfolders and with different filenames. What Python script or freeware program would you recommend for removing the ...
12
votes
1answer
3k views

How can I use the Homebrew Python version with Homebrew MacVim on Snow Leopard?

Note: For Mountain Lion, see: How can I use the Homebrew Python with Homebrew MacVim on Mountain Lion? I've installed Python 2.7 with Homebrew on Mac OS X Snow Leopard. When I install MacVim ...
11
votes
3answers
5k views

Python 2.6.1, pycrypto 2.3 pypi package: “Broken Pipe” during build

I am attempting to install Fabric, which requires pycrypto. During the build for pycrypto I always receive a "Broken Pipe" error. I don't know where to start to fix the problem. I'm running Mac OS X ...
11
votes
4answers
13k views

How To Add Python to the Windows Path

How do I add python to the windows PATH permanently?
10
votes
8answers
7k views

Vim: execute the script I'm working on in a split screen

I'm working on a small python script, which needs frequent execution in order to debug and further develop. Can I split the vim screen and execute my script on one part with a keystroke?
10
votes
1answer
14k views

How to find installation path for packages installed through apt-get in Ubuntu?

I have been installing python modules using apt-get which works great using the console or launching files from the command line. However I am using Eclipse for easier organisation of files. Eclipse ...
9
votes
5answers
32k views

How to install pip and easy_install on CentOS

I tried to install pip and easy_install on my CentOS but could not find them. How can I install them? Also, I have two versions of Python, 2.4 and 2.7. How will pip make sure to link newly installed ...
8
votes
3answers
592 views

How can I run my python program directly from the shell?

I wrote a script. When it starts, it won't stop, and it keeps getting data from the Internet. I can call it this way: cd /User/Desktop/project/internetScanner/ python3 main.py start But I would ...
8
votes
6answers
8k views

Installing pygame on Snow Leopard's system Python 2.6

Snow leopard has python 2.6 included now, and I want to install pygame on it, but it says its for Python from python.org, not system python. I tried using setup.py from source, but it didn't work. Is ...
8
votes
1answer
3k views

enabling colors in the python interactive shell on OS/X

I have just modified my .bash_profile so as to have colors in iTerm and Terminal. Now, I want to enable syntax highlighting for the Python interactive shell, IDLE-style. How to do that?
8
votes
2answers
8k views

How can I make a table of contents for a markdown document with Python/AWK/SED?

I have the following markdown document: Heading-a ========== ---text--- Heading-b ------------ --- text --- Heading-c ---------- --- text--- Heading-d ======= --- text---- Heading-e --- ... ...
8
votes
1answer
1k views

How to set up a own Chrome sync server?

I'm trying to set up a sync server for Chromium/Chrome, but i'm totally failed. I also couldn't find a How-To (like this here for Firefox) for that. I only found this question from '10 on superuser ...
7
votes
3answers
702 views

`which python` points to the python I want, but `python` runs the wrong version

I want to use python24 provided by ports, so I've installed it, and python_select -s shows that the version I want is indeed selected. Running which python gives /opt/local/bin/python, and running ...
7
votes
1answer
336 views

Why is Python for Windows not installed in %PROGRAMFILES% (“C:\Program Files”)?

Python was originally installed in C:\Program Files\Python, but that changed around 1.5. What was the reasoning behind that decision? Is it a bad idea to change the directory back, and if so, why?
7
votes
2answers
100 views

Is it possible to modify bash to run one command through another (say a python script)?

I was wondering if it is possible to modify bash such that when I type command --arg1 what actually happens is ~/prerun.py command --arg1 (prerun.py would handle starting command --arg1 itself) ...
7
votes
1answer
469 views

Get Python to raise MemoryError instead of eating all my disk space

If I run a Python program with a memory leak, I would normally expect the program to eventually die with MemoryError. But instead, what happens is that all the virtual memory is used until my disk ...
7
votes
4answers
2k views

How can I prevent the python.el that ships with Emacs 23 from EVER loading?

I use python-mode.el instead of python.el for python work, and all of my customizations depend on it. However, periodically for some reason the python.el that ships with Emacs23 will magically get ...
7
votes
5answers
2k views

How do I change the file association to a program with the same name in Windows 7?

Windows 7's file association controls have been "simplified" and now I appear to be unable to change the default association of a file (in my case a Python script) to a different executable. If I ...
7
votes
3answers
4k views

Preferred way to install multiple python versions on Ubuntu Jaunty

Situation: Jaunty ships with 2.6, which does not fit my needs because many libraries are still failing. I want to have a system default 2.5. Also, for testing purposes, I need 2.6, 2.5 and 2.4 ...
6
votes
10answers
10k views

Scripting: what is the easiest to extact a value in a tag of a XML file?

I want to read a pom.xml ('Project Object Model' of Maven) and extract the version information. Here is an example: <?xml version="1.0" encoding="UTF-8"?><project ...
6
votes
2answers
17k views

Why is pip not listed in easy_install on CentOS 6? Where to get it?

I am trying to install pip for python on CentOS 6. I thought of installing it through easy_install but it is not there. I tried to find easy_install with find command, but no luck. I tried to ...
6
votes
2answers
2k views

cron can't read PYTHONPATH environment variables?

I have added to the PYTHONPATH on my server's .bash_profile file. However it appears that cron isn't reading from it because I am getting import errors. If I run the exact command cron calls on the ...
6
votes
3answers
17k views

How do I properly update Python on Mac OS X

If I download python from the Python website and try to install it with the installer, it installs, but I need to specify that I want the new version of Python when I run my programs from terminal. If ...
6
votes
4answers
9k views

How do I write code of more than 1 line in the Python interpreter?

I have a problem coding Python in terminal. I'm just learning basics so I have no need to create .py files. In terminal I can run one line of code in the Python interpreter, but how do I write more ...
6
votes
2answers
2k views

How do I add “input” to my macro, to replace text in Notepad++?

I'm trying to make a macro with an 'input' pop-up dialog that synergizes with the replace feature. It should go something like: "Paste text->ask for input->replace variable in pasted text with input ...
6
votes
4answers
5k views

Making `#!/usr/bin/env python` work on Windows

I use Bash on Windows, provided by MSYS. I tried to run a Python file with a shebang of #!/usr/bin/env python, but I get this error message: /usr/bin/env: python: No such file or directory What ...
6
votes
4answers
7k views

How can I open Python files in IDLE from Windows?

I'm new to Python. I use Python 2.7 and I am running Windows Vista (64-bit). How do I make it when I click on .py scripts... that it opens up in IDLE so I can edit it a snap? Ya know... without having ...
5
votes
4answers
5k views

Adding programming code into LaTex / LyX

Maybe I'm just being thick, but I can't find any sensible way to simply paste in my (python) code into latex without losing all the indent information (kinda important for python). Anyone got any ...
5
votes
2answers
10k views

“bad interpreter: Permission denied” How can I prevent this error?

I want to run program directly such as ./program without define the interpreter in shell first. so, how can i want to prevent this error? bad interpreter: Permission denied My operating system ...
5
votes
4answers
20k views

Updating Python on Ubuntu system

I want to update the Python build on my Linux box, but the only way I know how to do it is uninstalling the current version and installing the new one. My system is already up to date (I updated ...
5
votes
4answers
3k views

vim could not load library python27.dll

I need Windows 7 + vim + python for writing vim plugins. :python print("hello") E370: Could not load library python27.dll E263: Sorry, this command is disabled, the Python library could not be ...
5
votes
3answers
7k views

Easy_install the wrong version of python modules (Mac OS)

I installed Python 2.7 on my Mac. When typing "python" in terminal, it shows: $ python Python 2.7 (r27:82508, Jul 3 2010, 20:17:05) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", ...
5
votes
2answers
7k views

How can I set up the python environment variable on Windows 7?

I would sure like to be able to type "python" on my command line instead of C:\Python27\python.exe. So to that end I'm trying to get the environment variable set up for myself. Problem is, I can't ...
5
votes
4answers
12k views

How can I update the default Python installation/fix my $PATH on Mac OS X 10.6.7?

I know this question has been asked before on this site, and I have found a couple worthy discussions, but the solutions I've found and tried do not work. I want to learn Python and I'm having trouble ...
5
votes
3answers
3k views

OS X Lion easy_install requires sudo …?

I'm on OS X Lion and wanting to setup python virtual environments. I want to use virtualenvwrapper. Can someone confirm that the correct way to do this is to install packages via easy_install (and ...
5
votes
1answer
2k views

How to install Python newt or snack in Mac OS X for byobu

I've installed byobu in Mac OS X 10.6.5. It will start, (i.e. it will start a screen session) but in order to run byobu-config and probably in order to do some other things I need a module called ...
5
votes
2answers
2k views

The suggested way to handle pip(easy_install) with homebrew?

I know there are brew-gem and brew-pip but it is still really easy to get confused. Let's say my Mac OS X is 10.7.2. There are at least, as far as I know, 3 locations for Python modules (assume ...
5
votes
2answers
3k views

Python IDLE disappeared from the right click context menu

My IDLE shortcut in the right click menu has disappeared. I think it's because I used to use Python 2.7, but I installed Python 2.5 without uninstalling Python2.7, and then uninstalled Python 2.5. I ...
5
votes
1answer
2k views

When a python process is killed on OSX, why doesn't it kill the child processes?

I found myself getting very confused a while back by some changes that I found when moving Python scripts from Linux over to OSX... On Linux, if a python script has called os.system(), and the ...
5
votes
3answers
5k views

Why do I get easy_install error “'NoneType' object has no attribute 'clone'”?

I'm trying to run the command: easy_install MySQLdb But, I'm getting the error: 'NoneType' object has no attribute 'clone' I'm using Windows 7 x64 with Python 2.6 x86 (I've tried Python x64, but ...
5
votes
1answer
2k views

Launch XBMC from command line and play movie from timepoint

What is the easiest way to launch XBMC and play a movie from a certain timepoint? Apparently there aren't many command line options (ref), and the XBMC python scripts seem to be designed to run from ...
4
votes
7answers
11k views

How to convert .xlsx to .txt?

I want to know if there is a Linux tool or a script available to convert .xlsx file to .txt.