Posts Tagged ‘pip’

pip install –user

June 29, 2018 Leave a comment

When we install something with pip, usually we do a “sudo pip install pkg_name“. However, there are some problems with this approach. First, you need root privileges. Second, it installs the package globally, which can cause conflicts in the system. Is there a way to install something with pip locally?

The good news is that you can install a package with pip locally too. Under Linux the destination folder by default is ~/.local . Add the following line to the end of your ~/.bashrc :

export PATH=~/.local/bin:$PATH

Then install the package locally. For instance, let’s install pipenv:

$ pip install pipenv --user

Open a new terminal (thus ~/.bashrc is read), and launch pipenv. It should be available. Let’s check where it is:

$ which pipenv

update all packages with pip in your virtual environment

January 5, 2017 Leave a comment

You want to update all installed packages in your virtual environment.


$ pip install pip-review
$ pip-review --local --interactive

Tip from here.

Categories: python Tags: ,

python uninstall

November 2, 2014 Leave a comment

Sometimes you need to install a software with “python install“. However, if you want to get rid of it, there is no “python uninstall” or “python remove”. Stupid, but true.

I found the solution here. In short:

# install:
$ (sudo) python install

# uninstall:
# then remove with pip:
$ (sudo) pip uninstall PACKAGE_NAME
Categories: python Tags: , ,


January 25, 2014 Leave a comment

“A set of two command line tools (pip-review + pip-dump) to help you keep your pip-based packages fresh, even when you’ve pinned them.

pip-review checks PyPI and reports available updates. It uses the list of currently installed packages to check for updates, it does not use any requirements.txt.

pip-dump dumps the exact versions of installed packages in your active environment to your requirements.txt file.”

I haven’t used it yet, so this post a reminder for me. I think I will need it soon.

Categories: python Tags: ,

PyPy is awesome

August 15, 2013 Leave a comment

PyPy is a fast, compliant alternative implementation of the Python language (2.7.3 and 3.2.3).

Visit the download page and get the 32-bit or 64-bit archive, depending on your architecture. I extracted it in the /opt directory and put a symbolic link on it:

jabba@jabba-uplink:/opt$ ls -al | grep pypy
lrwxrwxrwx  1 jabba jabba     8 Aug 15 12:32 pypy -> pypy-2.1
drwxr-xr-x  7 jabba jabba  4096 Jul 31 12:59 pypy-2.1

If you install a newer version, just update the symbolic link.

Put another symbolic link to /usr/bin called pypy that points to /opt/pypy/bin/pypy:

root@jabba-uplink:~# ls -al /usr/bin/pypy
lrwxrwxrwx 1 root root 18 Aug 15 16:39 /usr/bin/pypy -> /opt/pypy/bin/pypy

Try it:

jabba@jabba-uplink:~$ pypy
Python 2.7.3 (480845e6b1dd, Jul 31 2013, 09:57:07)
[PyPy 2.1.0 with GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Install pip for pypy
We also want to use 3rd party libraries with pypy thus we need pip.

$ wget
$ wget
$ pypy
$ pypy

Add the following alias to your ~/.bashrc:

alias pip_pypy='/opt/pypy/bin/pip'

Open a new terminal and you are ready to install 3rd party libraries. Example:

$ pip_pypy install futures    # import concurrent.futures

Tip from here. Getting started here.

Categories: python Tags: ,

update all pip packages

You want to update all the pip-installed Python packages on your system.

At there is a very nice little script for this task:

import pip
from subprocess import call

for dist in pip.get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)

I modified it a bit to update packages in ascending order by name in an ignore-case way:

#!/usr/bin/env python

import os
import pip

dists = []
for dist in pip.get_installed_distributions():

for dist_name in sorted(dists, key=lambda s: s.lower()):
    cmd = "sudo pip install {0} -U".format(dist_name)
    print '#', cmd

I want to update the packages globally, that’s why the “sudo“. If you run it, it will just print the commands to the stdout (dry run). If everything is OK, uncomment the last line.

Update (20140121)
I made a github project of it:

Categories: python Tags: , ,

Install a package with pip from a github repository

December 27, 2012 Leave a comment

You want to install a package from a GitHub repository via pip.

Let’s take an example. Say you want to install requests whose github address is

With pip you can istall it like this:

sudo pip install -U
Categories: python Tags: ,

Install a package via pip even if PyPI is down

December 2, 2012 Leave a comment

PyPI is down but still, you want to install a package.

Use a mirror, e.g.

sudo pip install -i <package_name>
Categories: python Tags: , , , ,

Upload your first project to PyPI

January 25, 2012 Leave a comment

Today I uploaded my jabbapylib project to PyPI, available here.

For preparing my first public pypi project, I followed this tutorial. For understanding how to package a Python library, read Mark Pilgrim’s corresponding book chapter.

I only want to add the following remarks:

  1. In, I import “from setuptools import setup, find_packages“. Notice setuptools instead of distutils.core.
  2. In the prepared package I wanted to include the library jabbapylib/ recursively since all the source codes are there. I could do that with this line: “packages = find_packages(exclude=['demos', 'dist', 'tests'])“, i.e. include all subdirectories with the exception of the ones in the list. What remains in my case is the “jabbapylib” folder.
  3. My library has some dependencies, they are specified here: “install_requires=['html5lib', 'psutil', 'pytest']“. When jabbapylib is installed with pip, pip will install these packages too.
  4. You can create your own file to specify what to include and what to exclude. However, if you want to add the directory that contains all the sources, do as indicated in step (2).
  5. For checking, packaging and uploading I made some simple scripts.

The Python Ecosystem

January 7, 2012 Leave a comment

Here is an excellent introductory article to the Python ecosystem including packages, pip, virtualenv (and virtualenvwrapper), and some other important tools (e.g. fabric). I wish I had read it a long time ago.

Categories: python Tags: , , , ,