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

29
votes
5answers
16k 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. ...
25
votes
4answers
66k 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
11k 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
2answers
2k views

Run Python scripts without explicitly invoking `python`

I'm using Debian Linux. I was wondering if there was a way to configure to run all Python scripts in the terminal by typing script.py (instead of python script.py).
15
votes
8answers
15k 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 ...
15
votes
2answers
15k 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 ...
15
votes
6answers
18k 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
3answers
49k 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 ...
13
votes
6answers
3k 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 ...
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
4answers
17k views

How To Add Python to the Windows Path

How do I add python to the windows PATH permanently?
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 ...
10
votes
8answers
8k 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
17k 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
43k 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 ...
9
votes
1answer
4k 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?
9
votes
4answers
9k 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 ...
8
votes
3answers
677 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
3answers
1k views

Find outdated/updatable pip packages

pip freeze shows me the packages installed, but how do I check against pypi which ones are outdated?
8
votes
3answers
829 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 ...
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
4answers
16k 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 ...
8
votes
2answers
9k 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
2k 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
5answers
6k 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 ...
7
votes
2answers
6k views

Python / Selenium / PhantomJS: “Unable to start phantomjs with ghostdriver.”

I'm trying to get Selenium to use phantomjs on a Windows machine. My code compiles without any error: from selenium import webdriver from selenium.webdriver.common.desired_capabilities import ...
7
votes
1answer
539 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
103 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
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 ...
7
votes
1answer
623 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

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 ...
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
13k 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
20k 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
3answers
18k 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
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
6k 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
2answers
219 views

Unexpected shutdown with heavy single threaded process and single core affinity

I'm not sure what's the cause of the problem, but it happened 3 times in two weeks under similar conditions. I checked with the laptop's support desk and they made me run several tests to see if my ...
5
votes
2answers
11k 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
1answer
1k views

%paste magic function on ipython3

I'm using ipython3 which I installed on Ubuntu with apt-get. I can't use he paste magic function, it complains about missing Tkinter. But I do have Tkinter and the same thing works fine on ipython ...
5
votes
2answers
1k views

Extremely slow pypi package retrieval with i.e. pip

Finding python packages using tools such as pip or easy_install takes very long, up to ten minutes, on my local desktop running Ubuntu 12.10. The same procedures are lightning fast on my cloud ...
5
votes
4answers
27k 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
4k 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
4answers
739 views

Can't type the “b” letter in Python shell in OS X

I have a problem with my "b" letter in Python shell in OS X. I can't type "b", but "B" worked fine. How can I solve this issue?
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
8k 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
2answers
294 views

Remote Python Shell

I'm teaching my friend how to program in Python. So far, we have been using Skype's screen sharing feature, but that is quite cumbersome and low resolution. Is there a way we can have a common shell ...