Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've installed Python 2.6.4 into (a subdirectory in) my home directory on a Linux machine with Python 2.3.4 pre-installed, because I need to run some code that I've decided would require too much work to make it run on 2.3.4. (I'm not on the sudoers list for that machine.)

I was hoping I could run ~/Python-2.6.4/python setup.py install (from the PyYAML directory in my home directory, where I untarred the PyYAML sources) and it would be smart enough to install it into my local Python 2.6.4 install. But it's not. (See the P.S.)

Is it possible to install PyYAML into my local Python install, so that "import yaml" will work when I invoke that Python? If so, how do I do that?

P.S. Here's the output when I ran ~/Python-2.6.4/python setup.py install:

running install
running build
running build_py
creating build/lib.linux-ppc64-2.6
creating build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/composer.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/nodes.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/dumper.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/resolver.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/events.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/emitter.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/error.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/loader.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/cyaml.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/scanner.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/__init__.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/serializer.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/reader.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/representer.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/constructor.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/tokens.py -> build/lib.linux-ppc64-2.6/yaml
copying lib/yaml/parser.py -> build/lib.linux-ppc64-2.6/yaml
running build_ext
creating build/temp.linux-ppc64-2.6
checking if libyaml is compilable
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -I/home/dspitzer/Python-2.6.4/Include
-I/home/dspitzer/Python-2.6.4 -c
build/temp.linux-ppc64-2.6/check_libyaml.c -o
build/temp.linux-ppc64-2.6/check_libyaml.o
build/temp.linux-ppc64-2.6/check_libyaml.c:2:18: yaml.h: No such file
or directory
build/temp.linux-ppc64-2.6/check_libyaml.c: In function `main':
build/temp.linux-ppc64-2.6/check_libyaml.c:5: error: `yaml_parser_t'
undeclared (first use in this function)
build/temp.linux-ppc64-2.6/check_libyaml.c:5: error: (Each undeclared
identifier is reported only once
build/temp.linux-ppc64-2.6/check_libyaml.c:5: error: for each function
it appears in.)
build/temp.linux-ppc64-2.6/check_libyaml.c:5: error: syntax error
before "parser"
build/temp.linux-ppc64-2.6/check_libyaml.c:6: error: `yaml_emitter_t'
undeclared (first use in this function)
build/temp.linux-ppc64-2.6/check_libyaml.c:8: warning: implicit
declaration of function `yaml_parser_initialize'
build/temp.linux-ppc64-2.6/check_libyaml.c:8: error: `parser'
undeclared (first use in this function)
build/temp.linux-ppc64-2.6/check_libyaml.c:9: warning: implicit
declaration of function `yaml_parser_delete'
build/temp.linux-ppc64-2.6/check_libyaml.c:11: warning: implicit
declaration of function `yaml_emitter_initialize'
build/temp.linux-ppc64-2.6/check_libyaml.c:11: error: `emitter'
undeclared (first use in this function)
build/temp.linux-ppc64-2.6/check_libyaml.c:12: warning: implicit
declaration of function `yaml_emitter_delete'

libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
 specify the option --include-dirs or uncomment and
 modify the parameter include_dirs in setup.cfg)
running install_lib
creating /usr/local/lib/python2.6
error: could not create '/usr/local/lib/python2.6': Permission denied
share|improve this question
add comment

2 Answers

Look into the --home or --user or --prefix switches for setup.py. These control where files get installed to.

From your build log though I'm not sure that's the problem. It looks like it's failing to find yaml.h. Is that part of the PyYAML sources? Or is it part of libyaml which PyYAML requires but you've neglected to install?

share|improve this answer
    
The missing yaml.h is part of the check for libyaml, which is optional. Note below that is "libyaml is not found or a compiler error: forcing --without-libyaml". (I don't need libyaml.) –  Daryl Spitzer Feb 16 '10 at 22:36
    
I see, I just noticed the errors following that. So if the only problem is permissions on the install location, then the switches I listed above should help you. You could begin with python setup.py --user install –  dubiousjim Feb 16 '10 at 22:56
add comment
up vote 0 down vote accepted

I didn't install Python correctly. When I followed Crast's instructions in http://stackoverflow.com/questions/2278028/how-do-i-work-around-this-problem-creating-a-virtualenv-environment-with-a-custom/2278059#2278059, I was then able to install PyYAML without problems. (With no need for virtualenv.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.