Skip to content Skip to sidebar Skip to footer

How Can I Install The Python Module Yaml Without Root Access ( 'easy_install' And 'pip' Are Not Available)?

I am trying to run a python script that calls the yaml module on a server. I only have writing permissions in my home directory. The server has Python 2.7.3 installed. I do not ha

Solution 1:

Setting up and using a virtualenv is almost always a good option and as you indicated you can download virtualenv.py, but that won't run (anymore) without pip being installed because it tries to install wheels. On Linux Mint with Python 2.7.6 the script e.g. throws:

OSError: Command /home/ruamel/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools wheel failed with error code 1

You can probably circumvent that by using an older virtualenv.py.

In some other cases it is not feasible to use a virtualenv: e.g. when the system python has all kinds of libraries pre-installed that you need to use and cannot replicate into a local virtualenv. In that case you can download the latest version of ruamel.yaml (of which I am the author) and which is essentially a superset of the PyYAML functionality. When I forked the code I created a setup.py from scratch and it allows you to do

python setup.py install --user

without problem on the `setup.py extracted from the tar.gz file downloaded from PyPI.

Solution 2:

Based on the idea of the answer by Anton, these steps worked for me

pip install --user ruamel.yaml

then replace in your script

import yaml

with:

from ruamel.yamlimportYAML
yaml=YAML(typ='safe')

Post a Comment for "How Can I Install The Python Module Yaml Without Root Access ( 'easy_install' And 'pip' Are Not Available)?"