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 have root access. Also, neither pip nor easy_install are available.
I have downloaded the package and tried to run
python setup.py install --user
which gives the error
error: can't combine user with with prefix/exec_prefix/home or install_(plat)base
How can I get this to work?
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 eg 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: eg 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.
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.yaml import YAML
yaml=YAML(typ='safe')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.