Я установил Python 2.6.4 в (подкаталог в) мой домашний каталог на машине Linux с предварительно установленным Python 2.3.4, потому что мне нужно запустить некоторый код, который, как я решил, потребует слишком много работы, чтобы сделать его запустить на 2.3.4. (Меня нет в списке sudoers для этой машины.)
Я надеялся, что смогу бежать ~/Python-2.6.4/python setup.py install
(из каталога PyYAML в моем домашнем каталоге, где я распаковал исходные коды PyYAML), и было бы достаточно умен, чтобы установить его в мою локальную установку Python 2.6.4. Но это не так. (См. P.S.)
Можно ли установить PyYAML в мою локальную установку Python, чтобы "import yaml" работал, когда я вызываю этот Python? Если да, то как мне это сделать?
P.S. Вот результат, когда я запустил ~/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
Посмотрите в --home
или --user
или --prefix
переключатели для setup.py. Они контролируют, куда устанавливаются файлы.
Судя по журналу сборки, я не уверен, что проблема в этом. Похоже, он не может найти yaml.h. Это часть источников PyYAML? Или это часть libyaml, которую требует PyYAML, но вы забыли ее установить?
Я неправильно установил Python. Когда я последовал Crastинструкции в https://stackoverflow.com/questions/2278028/how-do-i-work-around-this-problem-creating-a-virtualenv-environment-with-a-custom/2278059#2278059, Я смог без проблем установить PyYAML. (Без virtualenv.)