1

I am trying to install dropbox on my university host, and that requires python module docutils. So, after downloading the module and running python install.py I get the following output:

running install
running build
running build_py
running build_scripts
running build_data
running install_lib
creating /usr/local/lib/python2.7/dist-packages/docutils
error: could not create '/usr/local/lib/python2.7/dist-packages/docutils': Read-only file system

Not surprising really, I can't do any writing outside my home directory. My question is - is there a way to install it in my home folder?

Thanks

Yotam
  • 9,789
  • 13
  • 47
  • 68
  • possible duplicate of [How to install python modules without root access?](http://stackoverflow.com/questions/7465445/how-to-install-python-modules-without-root-access) – Wooble Apr 09 '13 at 17:18

3 Answers3

3

With the latest version of pip, one way to do it is:

pip install --user project
Jakob Bowyer
  • 33,878
  • 8
  • 76
  • 91
  • Hey, I tried 'pip install -t ./docutils docutils-0.10.tar.gz' - got a lot of warnings but also 'Successfully installed docutils'. When running dropbpx ./configure I have the same problem - ot doesn't recognize the module. Does pip let python interpreter know that there's a module isntalled locally, or do I have to specify it when I import it? – Yotam Apr 09 '13 at 17:16
  • `-t` requires an install location; `--user` should put it somewhere that Python already looks for modules (where possible). – Wooble Apr 09 '13 at 17:20
  • So if I type '--user ~/modules' flag I tell python to look for modules in '~/modules'? – Yotam Apr 09 '13 at 17:25
  • 1
    no, `--user` doesn't take an argument; pip and python know where your user python modules directory should be. – Wooble Apr 09 '13 at 17:32
2

The best way to circumvent system level modifications/additions when acquiring python modules is to use virtualenv and its wrapper, to make it easier, virtualenvwrapper, along with pip. Perhaps these are already installed? Try

$ mkvirtualenv dropboxEnv # or whatever you want to call it
$ workon dropboxEnv       # to activate the virtual environment

and/or

$ pip install docutils

if you don't have pip you can first try

$ easy_install pip

AFAIK, a virtualenv is the only way to "install" a module into your home folder. Trying to get virtualenv/virtualenvwrapper installed might be a good option. If those aren't already installed, you might try to find someone to install those on your machine system-wide, then you would be able to create any virtualenvs and install any modules you want into your home folder.

samstav
  • 1,945
  • 1
  • 20
  • 20
  • 1
    `virtualenv` is convenient but not the only way to install a Python module into your home folder. An other answer mentions the `--user` configuration option supported by Distutils and pip. You can also use the `PYTHONPATH` enviornment variable or dynamically `sys.path`. – Ned Deily Apr 09 '13 at 18:08
  • Nice. Didn't know about the --user tag. Thanks. I am aware of PYTHONPATH, but what do you mean by "you can also use the PYTHONPATH environment variable?" in this scenario? – samstav Apr 10 '13 at 01:32
  • 2
    You can install Python modules in any directory and then set `PTYHONPATH` to add that directory to the search path Python uses when importing modules. There are times when that may be more appropriate than using a `virtualenv`. But, for many use cases, `virtualenv` is simpler. – Ned Deily Apr 10 '13 at 04:24
0

If you have downloaded version try this

python setup.py install --user
Serjik
  • 10,543
  • 8
  • 61
  • 70